我正试图让谷歌的OAuth2在iOS应用程序中进行用户验证。
我正在使用google,但无法让它与OAuth2Client一起工作。谷歌似乎只接受http://localhost或urn:ietf:wg:oauth:2.0:oob作为重定向url。阻止我使用自定义模式来触发切换回我的应用程序。
代码如下所示:
[[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"];当我运行它时,Safari会出现并请求访问,但是由于无法重定向到应用程序,所以会陷入困境。
有人知道如何使这个工作,或者我需要一个不同的api?注意:我目前无法访问Google工具箱OAuth2工具包ATM。
发布于 2012-06-26 01:18:59
最后得到了GTM-OAuth2代码,这似乎是可行的。
https://stackoverflow.com/questions/11131980
复制相似问题