我已將Google登錄集成到我的iOS應用中,並在登錄後檢索訪問令牌。我現在想要向Google授權API調用,但不確定如何執行此操作包括令牌。
有人可以分享一些我可以用來包含這個代碼嗎?
非常感謝,
盧克製作iOS授權的Google API調用
3
A
回答
2
你已經登錄並獲得令牌,創建服務實例,然後附加一個經過「授權」。谷歌的Objective-C的客戶端支持相當多的服務:https://code.google.com/p/google-api-objectivec-client/
下面是使用Google+的一個樣本:
的OBJ-C(與ARC啓用)
GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
plusService.retryEnabled = YES;
# set an authorizer with your tokens
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
# submit authenticated queries, assuming your scopes & tokens are legit
GTLQueryPlus *query = [GTLQueryPlus queryForPeopleListWithUserId:@"me"
collection:kGTLPlusCollectionVisible];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPeopleFeed *peopleFeed,
NSError *error) {
// ... your callback ...
}];
斯威夫特
var plusService = GTLServicePlus()
plusService.retryEnabled = true
# set an authorizer with your tokens
plusService.authorizer = GPPSignIn.sharedInstance().authentication
if let plusQuery = GTLQueryPlus.queryForPeopleListWithUserId("me",
collection: kGTLPlusCollectionVisible) as? GTLPlusQuery {
// execute the query
plusService.executeQuery(plusQuery) { (ticket: GTLServiceTicket!,
peopleFeed: GTLPlusPeopleFeed!,
error: NSError!) -> Void in
// ... your callback ...
}
}
There is a sample使用Google Obj-C專門針對YouTube的API客戶端。查看229行YouTubeSampleWindowController.m
設置您的GTLServiceYouTube
對象,行261查看與GTLQueryYouTube
對象配合使用的示例。
還有一些不錯的CocoaDocs。 This method可能是你之後的事情。
0
相關問題
- 1. 無法授權Google Directory Admin API調用
- 2. Google Tasks API授權
- 3. Google API - 強制授予權限每次
- 4. Slack Oauth /授權API調用
- 5. Google api長時間授權
- 6. Google Gmail API - 授權設置
- 7. 授權Android Google Drive API
- 8. 授權Google Drive Android API
- 9. Google API授權失敗
- 10. Google Plus API授權:request_visible_actions
- 11. 如何授權使用google-api-ruby-client
- 12. 使用Google登錄授權YouTube Data API
- 13. Google Contacts API:如何重用授權碼?
- 14. 使用ClientLogin在Google Tasks API中授權
- 15. Google ClientLogin授權
- 16. IOS JSON授權
- 17. MobileServices.web.js未授權的API調用
- 18. Google Reader API:未經授權的搜索?
- 19. Google Drive Api的帳戶授權
- 20. Google Adwords API錯誤:無效的授權
- 21. 訪問Google API時的授權無效
- 22. 調用Google Admin SDK Directory API時未經授權
- 23. Google數據(日曆)API授權授權 - 前端
- 24. Google驅動器php API授權失敗,出現無效授權
- 25. Google Drive API授權訪問,無需人工授權
- 26. 使用JavaScript SDK API調用授權
- 27. AWS Cognito使用Javascript授權API調用
- 28. Google Firebase中的授權
- 29. 添加授權在angular2 API調用頭
- 30. Google Drive Api - 未經授權文件
您能否鏈接到哪個頁面?理想情況下,您可以爲YouTube提供一個equivilent嗎?我關注了這個鏈接,當我點擊這些服務時,它只是把我帶到他們開發人員的主頁上。感謝 – mylogon
https://developers.google.com/+/mobile/ios/people,以及我自己的Swift示例代碼。這裏還有一個YouTube API示例:https://code.google.com/p/google-api-objectivec-client/source/browse/#svn%2Ftrunk%2FExamples%2FYouTubeSample – sgammon
添加了一些鏈接和代碼參考爲YouTube。希望那些幫助! – sgammon