0

我从这个例子开始一个演示应用程序

https://github.com/Christian-Hansen/simple-oauth2

我可以验证 ti google 并取回 AUTH 对象。如果我 NSLog 身份验证对象,我可以看到 access_token、过期日期和代码,但没有刷新令牌。这正常吗?因为一段时间后我无法请求导致我的访问令牌已过期..我还添加了:

-(void)awakeFromNib 方法与 auth.canAuthorize

我做错了什么?谢谢

4

2 回答 2

4

谢谢@grobbins。关键是我需要在请求中添加这些参数:

    viewController.signIn.additionalAuthorizationParameters = 
    [NSDictionary dictionaryWithObjects:[NSArray 
arrayWithObjects:@"offline",@"force", nil] forKeys:[NSArray arrayWithObjects:@"access_type",@"approval_prompt", nil]];

希望对外面的人有用!:-)

于 2013-04-17T14:01:13.777 回答
0

使用 authenticationWithServiceProvider:登录到 Google 以外的服务时,但对于那些服务,不要使用 Google 的令牌 URL;使用服务提供者的令牌 URL。

登录 Google 时,不要创建 auth 对象;只需调用 GTMOAuth2ViewControllerTouch +controllerWithScope:。如果用户登录成功,回调中包含 auth 对象。

比较示例应用登录 Google 服务和非 Google 服务的方式,以了解不同的方法。

于 2013-04-06T16:16:52.003 回答