我需要从YouTube-api获取auth code
,然后将其传递给服务器端,然后尝试使用access token
检索auth code
。有没有办法让auth code
使用Google登录库?
现在我只能在设备上获得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
}
我发现在没有使用 auth code
的情况下无法获取webview
。