2012-09-16 74 views
0

我試圖獲取Picasa的請求令牌以脫機訪問相冊和照片。我能夠使用這兩個參數(access_type和approval_prompt)從服務器端請求它,但我不知道如何將它們傳遞給iPhone客戶端(GTMOAuth2Authentication和GTMOAuth2ViewControllerTouch)。Google的GTMOAuth2Authentication客戶端是否支持授予離線訪問權限?

ACCESS_TYPE =離線& approval_prompt =力」

任何幫助,將不勝感激。

謝謝!

+0

你有沒有想過這個? – jj0b

回答

0

找到了答案。你發出請求之前設置在GTMOAuth2SignIn additionalAuthorizationParameters屬性參數。

GTMOAuth2ViewControllerTouch *viewController; 

[[viewController signIn] setAdditionalAuthorizationParameters:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"offline",@"force", nil] forKeys:[NSArray arrayWithObjects:@"access_type",@"approval_prompt", nil]]]; 
0
-(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]; 
} 

希望對你有所幫助..

相關問題