Google Plus iOS SDK 不刷新过期令牌 [英] Google Plus iOS SDK not refreshing expired token

查看:60
本文介绍了Google Plus iOS SDK 不刷新过期令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,可能有一个很简单的解决方案,但我看不到它.

I have a problem, which might have a so simple solution, that I am not able to see it.

我将 Google Plus iOS SDK 安装到我的应用中,并且让我的应用在 Google 上运行得非常好.

I installed the Google Plus iOS SDK into my app, and got my app running with Google very nice.

Google Plus iOS SDK

但是,一小时后,令牌即将到期,我找不到更新它的方法.

BUT, after one hour, the token is expiring, and I don't find a way to renew it.

- (void)renewGoogleToken {
    GPPSignIn *gppSignIn                        = [GPPSignIn sharedInstance];
    gppSignIn.shouldFetchGooglePlusUser         = YES;
    gppSignIn.shouldFetchGoogleUserEmail        = YES;
    gppSignIn.clientID                          = [DSUtils getGoogleClientID];
    gppSignIn.scopes                            = @[@"https://www.googleapis.com/auth/plus.login",
                                                @"https://www.googleapis.com/auth/calendar"];
    gppSignIn.delegate                          = self;

    BOOL success                                = [gppSignIn trySilentAuthentication];  }

当我想使用 Google+ 登录时,我最初会调用此方法.一小时后,当令牌即将到期时,我再次调用此方法,但收到相同的令牌,即将到期.

I call this method initially, when I want to login with Google+. After one hour, when token is about to expire, I call this method again, but I receive same token, which is about to expire.

有人可以帮我吗?我在谷歌上进行了大量搜索,但找不到解决方案.SDK Docs 没有说任何关于更新的内容,这很奇怪.令牌是否自动刷新?

Anybody can help me please? I searched intensely on google, and could not find a solution. The SDK Docs doesn't say anything about renewing, which is strange. Is token refreshed automatically?

请帮忙,谢谢.

推荐答案

返回的对象是 GTMOAuth2Authentication.如果在常规 Google 服务请求中使用,则应在需要时自动刷新.但是,如果您需要强制刷新,则可以请求对 nil 请求进行授权:

The object you get back is a GTMOAuth2Authentication. If being used in a regular Google service request, it should automatically be refreshed automatically if needed. However, if you need to force a refresh you can request authorization of a nil request:

[auth authorizeRequest:nil
          delegate:self     
 didFinishSelector:@selector(authentication:request:finishedWithError:)];

或者用块

[auth authorizeRequest:nil 
 completionHandler:^(NSError *error) { //...
}];

这篇关于Google Plus iOS SDK 不刷新过期令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆