Android 使用Google登录获取授权代码
我需要从YouTube api获取Android 使用Google登录获取授权代码,android,oauth-2.0,youtube-api,google-signin,Android,Oauth 2.0,Youtube Api,Google Signin,我需要从YouTube api获取auth-code,将其传递到服务器端,然后服务器端尝试使用auth-code检索access-token。有没有办法通过谷歌登录库获取auth code 现在我只能在设备上获取accessToken: val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data) if (result.isSuccess) { // Get the account from the sign in r
auth-code
,将其传递到服务器端,然后服务器端尝试使用auth-code
检索access-token
。有没有办法通过谷歌登录库获取auth code
现在我只能在设备上获取accessToken
:
val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
if (result.isSuccess) {
// Get the account from the sign in result
val account = result.signInAccount
// Store the account from the result
mAccount = account?.account
...
// Asynchronously access the People API for the account
val credential = GoogleAccountCredential.usingOAuth2(context, Collections.singleton(YOUTUBE_SCOPE))
credential.selectedAccount = mAccount
val token = credential.token
}
我发现,如果不使用
webview
,就无法获得auth code
。@noogui,是的,“谷歌登录”是我尝试使用的“已安装应用程序流”的建议替代方案。问题是,有没有办法使用这个“谷歌登录”库获取授权码(而不是访问令牌)?