Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用Google登录获取授权代码_Android_Oauth 2.0_Youtube Api_Google Signin - Fatal编程技术网

Android 使用Google登录获取授权代码

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

我需要从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 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,是的,“谷歌登录”是我尝试使用的“已安装应用程序流”的建议替代方案。问题是,有没有办法使用这个“谷歌登录”库获取授权码(而不是访问令牌)?