在弹出窗口中打开Goog​​le SignIn用户身份验证,需要使用OAuth 2.0在同一个Tab中打开

时间:2016-02-18 07:30:54

标签: google-api google-authentication google-signin googlesigninaccount googlesigninapi

我正在使用OAuth 2.0 for google SingIn,它正在打开一个用户身份验证的弹出窗口,但我想在同一个标​​签中打开,请帮帮我。 提前谢谢。

2 个答案:

答案 0 :(得分:3)

如果您使用Google登录JavaScript库,则会打开弹出窗口。您必须使用服务器端api客户端库来进行身份验证/授权而无需弹出窗口。 https://developers.google.com/identity/protocols/OAuth2WebServer

答案 1 :(得分:0)

您可以使用private void getDataFromApi(Context context) { // status.setValue(Status.LOADING); // start showing progressbar instead of setting the status // or actually u can do both depending on the usage of the `status` variable MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); ProgressBar progressBar = new ProgressBar(this); progressBar.setIndeterminate(true); builder.setView(progressBar); final AlertDialog dialog = builder.show(); Call<AllData> call = RetrofitService.getEndPoints().getAllData(Constants.API_KEY); call.enqueue(new Callback<AllData>() { @Override public void onResponse(Call<AllData> call, Response<AllData> response) { } if (response.isSuccessful()) { //staus.setValue(Status.SUCCESS); //dismiss the progress in success dialog.dismiss(); _allData.setValue(response.body()); } @Override public void onFailure(Call<AllData> call, Throwable t) { //staus.setValue(Status.ERROR); } }); } 将Google更改为重定向模式,该模式将在同一标签中而不是ux_mode: redirect中打开。
参考:https://developers.google.com/identity/sign-in/web/reference#gapiauth2clientconfig

然后在您的重定向登录页面上,使用popup来检索已登录的Google User对象。


(我知道这是一个老问题,但这是网络搜索的第一个结果;认为这也可能会帮助其他人)

相关问题