通过Google登录获取授权码

时间:2018-05-24 11:26:10

标签: android oauth-2.0 youtube-api google-signin

我需要从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

0 个答案:

没有答案
相关问题