【问题标题】:Does Google's GTMOAuth2Authentication client support granting offline access?Google 的 GTMOAuth2Authentication 客户端是否支持授予离线访问权限?
【发布时间】:2014-12-17 14:39:41
【问题描述】:

我正在尝试获取 Picasa 离线访问相册和照片的请求令牌。我可以使用这两个参数(access_type 和approval_prompt)从服务器端请求它,但我不确定如何将它们传递给iPhone客户端(GTMOAuth2Authentication 和GTMOAuth2ViewControllerTouch)。

access_type=offline&approval_prompt=force"

任何帮助将不胜感激。

谢谢!

【问题讨论】:

  • 你有没有想过这个问题?

标签: iphone picasa


【解决方案1】:

找到了答案。在发出请求之前,您在 GTMOAuth2SignIn additionalAuthorizationParameters 属性中设置参数。

GTMOAuth2ViewControllerTouch *viewController;

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

【讨论】:

    【解决方案2】:
    -(void)showGoogleLoginPage{
        SEL finishedSelector = @selector(viewController:finishedWithAuth:error:);
        GTMOAuth2ViewControllerTouch *authViewController =
        [[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeDrive
                                                   clientID:kClientID
                                               clientSecret:kClientSecret
                                           keychainItemName:userKeyChainName
                                                   delegate:self
                                           finishedSelector:finishedSelector];
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjects:[NSArray
                                                                                  arrayWithObjects:@"offline",@"force",@"en", nil] forKeys:[NSArray arrayWithObjects:@"access_type",@"approval_prompt",@"hl", nil]];
    
        authViewController.signIn.shouldFetchGoogleUserProfile = YES;
        authViewController.signIn.additionalAuthorizationParameters=params;
        [self presentViewController:authViewController animated:YES completion:nil];
    }
    

    希望对您有所帮助..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      • 2020-01-31
      • 2012-03-02
      相关资源
      最近更新 更多