Token expiration is normal for OAuth 2 (and is handled by the gtm-oauth2 library) but I've not before seen it in an OAuth 1 implementation. I do not know if other Oauth 1 providers support that extension.
The gtm-oauth library does add any additional query parameters from the request to the signature string, so there is typically no need to modify the library for additional parameters. Single-step through signatureForParams:request: to see how the signature is created.
It will be necessary to modify the authentication class to support the session handle. Add a sessionHandle property and accessors:
@property (nonatomic, copy) NSString *sessionHandle;
static NSString *const kOAuthSessionHandleKey = @"oauth_session_handle";
- (NSString *)sessionHandle {
return [paramValues_ objectForKey:kOAuthSessionHandleKey];
}
- (void)setSessionHandle:(NSString *)str {
[paramValues_ setValue:[[str copy] autorelease]
forKey:kOAuthSessionHandleKey];
}
and set it in -setKeysForResponseDictionary:
NSString *sessionHandle = [dict objectForKey:kOAuthSessionHandleKey];
if (sessionHandle) {
[self setSessionHandle:sessionHandle];
}
Add kOAuthSessionHandleKey to the array in +tokenResourceKeys, and I think it will need to be excluded from the authorization header despite having an "oauth_" prefix, so in addAuthorizationHeaderToRequest:forKeys: specifically make an exception for it:
BOOL hasPrefix = [name hasPrefix:@"oauth_"] && ![name isEqual:kOAuthSessionHandleKey];
The a refresh request looks like
NSString *urlStr = @"
https://api.login.yahoo.com/oauth/v2/get_token";
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[mAuth authorizeRequest:request];
With an unexpired token, the server is responding to that request for me with "oauth_problem=token_rejected" but is apparently happy with request signature.