@@ -339,15 +339,13 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
339
339
[client authorizeWithUrl: providerName
340
340
url: callbackUrl
341
341
cfg: cfg
342
+ store: [manager accountStore ]
342
343
343
344
onSuccess: ^(DCTAuthAccount *account) {
344
345
NSDictionary *accountResponse = [manager getAccountResponse: account cfg: cfg];
345
346
_pendingAuthentication = NO ;
346
347
[manager removePending: client];
347
348
348
- DCTAuthAccountStore *store = [manager accountStore ];
349
- [store saveAccount: account];
350
-
351
349
callback (@[[NSNull null ], @{
352
350
@" status" : @" ok" ,
353
351
@" response" : accountResponse
@@ -515,21 +513,25 @@ - (NSDictionary *) getAccountResponse:(DCTAuthAccount *) account
515
513
516
514
if ([version isEqualToString: @" 1.0" ]) {
517
515
DCTOAuth1Credential *credential = account.credential ;
518
- NSDictionary *cred = @{
519
- @" access_token" : credential.oauthToken ,
520
- @" access_token_secret" : credential.oauthTokenSecret
521
- };
522
- [accountResponse setObject: cred forKey: @" credentials" ];
516
+ if (credential != nil ) {
517
+ NSDictionary *cred = @{
518
+ @" access_token" : credential.oauthToken ,
519
+ @" access_token_secret" : credential.oauthTokenSecret
520
+ };
521
+ [accountResponse setObject: cred forKey: @" credentials" ];
522
+ }
523
523
} else if ([version isEqualToString: @" 2.0" ]) {
524
524
DCTOAuth2Credential *credential = account.credential ;
525
- NSMutableDictionary *cred = [@{
526
- @" access_token" : credential.accessToken ,
527
- @" type" : @(credential.type )
528
- } mutableCopy];
529
- if (credential.refreshToken != nil ) {
530
- [cred setValue: credential.refreshToken forKey: @" refresh_token" ];
525
+ if (credential != nil ) {
526
+ NSMutableDictionary *cred = [@{
527
+ @" access_token" : credential.accessToken ,
528
+ @" type" : @(credential.type )
529
+ } mutableCopy];
530
+ if (credential.refreshToken != nil ) {
531
+ [cred setValue: credential.refreshToken forKey: @" refresh_token" ];
532
+ }
533
+ [accountResponse setObject: cred forKey: @" credentials" ];
531
534
}
532
- [accountResponse setObject: cred forKey: @" credentials" ];
533
535
}
534
536
[accountResponse setValue: [account identifier ] forKey: @" identifier" ];
535
537
if (account.userInfo != nil ) {
0 commit comments