2015-11-06 39 views

回答

3

谷歌登錄爲iOS的實施,允許您與您的谷歌帳戶登錄。爲了有能力獲得YouTube的數據也需要額外的範圍配置如下:

let scope: NSString = "https://www.googleapis.com/auth/youtube.readonly" 
let currentScopes: NSArray = GIDSignIn.sharedInstance().scopes 
GIDSignIn.sharedInstance().scopes = currentScopes.arrayByAddingObject(scope) 

現在,你可以訪問令牌運行下面的YouTube數據API:

https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token={oauth_token} 

的訪問令牌,你將從user.authentication.accessToken得到