我正在尝试获取 Picasa 离线访问相册和照片的请求令牌。我可以使用这两个参数(access_type 和approval_prompt)从服务器端请求它,但我不确定如何将它们传递给iPhone客户端(GTMOAuth2Authentication 和GTMOAuth2ViewControllerTouch)。
access_type=offline&approval_prompt=force"
任何帮助将不胜感激。
谢谢!
找到了答案。在发出请求之前,您在 GTMOAuth2SignIn additionalAuthorizationParameters 属性中设置参数。
GTMOAuth2ViewControllerTouch *viewController;
[[viewController signIn] setAdditionalAuthorizationParameters:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"offline",@"force", nil] forKeys:[NSArray arrayWithObjects:@"access_type",@"approval_prompt", nil]]];
-(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];
}
希望这对你有帮助..