@@ -379,6 +379,8 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
379379 return ;
380380 }
381381
382+ NSDictionary *creds = [self credentialForAccount: providerName cfg: cfg];
383+
382384 // If we have the http in the string, use it as the URL, otherwise create one
383385 // with the configuration
384386 NSURL *apiUrl;
@@ -394,8 +396,18 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name
394396 NSDictionary *params = [opts objectForKey: @" params" ];
395397 if (params != nil ) {
396398 for (NSString *key in params) {
397- NSURLQueryItem *item = [NSURLQueryItem queryItemWithName: key value: [params valueForKey: key]];
398- [items addObject: item];
399+
400+ NSString *value = [params valueForKey: key];
401+
402+ if ([value isEqualToString: @" access_token" ]) {
403+ value = [creds valueForKey: @" access_token" ];
404+ }
405+
406+ NSURLQueryItem *item = [NSURLQueryItem queryItemWithName: key value: value];
407+
408+ if (item != nil ) {
409+ [items addObject: item];
410+ }
399411 }
400412 }
401413
@@ -479,6 +491,31 @@ - (DCTAuthAccount *) accountForProvider:(NSString *) providerName
479491 }
480492}
481493
494+ - (NSDictionary *) credentialForAccount : (NSString *)providerName
495+ cfg : (NSDictionary *)cfg
496+ {
497+ DCTAuthAccount *account = [self accountForProvider: providerName];
498+ if (!account) {
499+ return nil ;
500+ }
501+
502+ id credentials;
503+ NSString *version = [cfg valueForKey: @" auth_version" ];
504+ if ([version isEqualToString: @" 1.0" ]) {
505+ credentials = [account credential ];
506+ } else if ([version isEqualToString: @" 2.0" ]) {
507+ credentials = [account credential ];
508+ } else {
509+ return nil ;
510+ }
511+
512+ NSDictionary *dict = @{
513+ @" access_token" : [credentials accessToken ]
514+ };
515+
516+ return dict;
517+ }
518+
482519- (DCTAuthRequestMethod) getRequestMethodByString : (NSString *) method
483520{
484521 if ([method compare: @" get" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
0 commit comments