質問

I'm trying to get Google's OAuth2 working for user verification in an iOS app.

I'm using the OAuth2Client api but cannot get it working with google. It appears that google only accepts http://localhost or urn:ietf:wg:oauth:2.0:oob as the redirect url. Stopping me from using a custom schema to trigger a switch back to my app.

The code looks like this:

[[NXOAuth2AccountStore sharedStore] setClientID:@"<client-id>"
                                         secret:@"<secret>"
                               authorizationURL:[NSURL URLWithString:@"https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile"]
                                       tokenURL:[NSURL URLWithString:@""]
                                    redirectURL:[NSURL URLWithString:@"http://localhost"]
                                 forAccountType:@"Google"];
[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"Google"];

When I run it, Safari appears and asks for access, but then gets stuck because I cannot redirect back to the app.

Anyone know how to make this work or do I need a different api? Note: I cannot currently get access to Google toolbox OAuth2 kit ATM.

役に立ちましたか?

解決

Finally got the GTM-OAuth2 code and that appears to be working.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top