Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTMOAuth2Authentication expiresIn can return wrong type #17

Closed
GoogleCodeExporter opened this issue Aug 11, 2015 · 1 comment
Closed

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Using Paypal endpoint (sandbox was tested)
2. Login with sandbox credentials
3. method updateExpirationDate throws exception on 
   unsigned long deltaSeconds = [expiresIn unsignedLongValue]; 
-[__NSCFString unsignedLongValue]: unrecognized selector sent to instance 
0x76db300

expiresIn is a NSString because it was sent as quoted string in the JSON 
response from server

What is the expected output? What do you see instead?
exception thrown on completion

What version of the product are you using? On what operating system?
iOS 6 - new application

Please provide any additional information below.

Properties are assigned to GTMOAuth2Authentication properties blindly from  
JSON parsed data, so some implementations may return NSString in token response.

In my case here is the Paypal (truncated) response to 
https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice

{
    "token_type": "Bearer",
    "expires_in": "28800",
    "refresh_token": "XXXXX",
    "id_token": "YYYYYY",
    "access_token": "ZZZZZZ"
}

Would suggest changing implementation of expiresIn to:

- (NSNumber *)expiresIn {
    id value = [self.parameters objectForKey:kOAuth2ExpiresInKey];

    if ([value isKindOfClass:[NSString class]]) {
        value = [NSNumber numberWithInteger:[value integerValue]];
    }
    return value;
}


Original issue reported on code.google.com by tbran...@gmail.com on 11 Sep 2013 at 10:20

@GoogleCodeExporter
Copy link
Author

Thanks for the issue report. We've incorporated your suggestion.

https://code.google.com/p/gtm-oauth2/source/detail?r=117

Original comment by grobb...@google.com on 12 Sep 2013 at 10:37

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant