2013-08-16 119 views
0

我使用GTL framework將Google Plus集成到我的可可應用程序中。Google Plus API授權:request_visible_actions

當我試圖插入一個新的時刻,它會失敗,錯誤401(未授權)。在this後,通過在將用戶重定向到授權頁面時包含request_visible_actions參數來解決此問題。但如何做到這一點?

我收到了一個自動創建URL的GTMOAuth2WindowController的實例。那麼如何添加request_visible_actions參數?如果這是不可能的,如何創建整個URL?

+0

你可以告訴我怎麼你設置了谷歌加時刻POST請求?我的工作不正常:((http://stackoverflow.com/questions/24061521/cannot-insert-moment-google-plus-api) – Supertecnoboff

回答

3

我解決了這個問題!我不得不創建GTMOAuth2WindowController這樣的:

GTMOAuth2Authentication *auth = [GTMOAuth2SignIn standardGoogleAuthenticationForScope:kGTLAuthScopePlusLogin clientID:kClientID clientSecret:kClientSecret]; 
NSString *authURLString = [[[GTMOAuth2SignIn googleAuthorizationURL] absoluteString] stringByAppendingString:@"?request_visible_actions=http://schemas.google.com/AddActivity"]; 

NSBundle *frameworkBundle = [NSBundle bundleForClass:[GTMOAuth2WindowController class]]; 
GTMOAuth2WindowController *windowController = [GTMOAuth2WindowController controllerWithAuthentication:auth 
                             authorizationURL:[NSURL URLWithString:authURLString] 
                              keychainItemName:nil 
                              resourceBundle:frameworkBundle]; 
+0

所以你連接「?request_visible_actions = http://schemas.google.com/AddActivity「改爲」https://accounts.google.com/o/oauth2/auth/「??? – Supertecnoboff