错误12501认证与谷歌登入 [英] Error 12501 authenticating with google sign-in

查看:4610
本文介绍了错误12501认证与谷歌登入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌登录服务来验证用户身份使用我的应用程序。我得到它的工作时,我只是要求以电子邮件的信息

  GoogleSignInOptions GSO =新GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestEmail()建立()。

然后,我想通了,我还需要请求ID令牌能够与我的后端进行验证,所以我所做的:

  GoogleSignInOptions GSO =新GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(将String.valueOf(R.string.server_client_id))
                    .requestEmail()建立()。

问题是,它不会让我登录到更改后。我把每一次我尝试登录获取状态状态{状态code =未知状态code:12501,分辨率= NULL}

我一直在寻找周围,我发现这个帖子是pretty很多关于同样的事情。但是,我没有做任何由谁回答的人命名的失误,在我的dev控制台OAuth用户端ID是Web应用程序:

R.string.server_client_id 是图片中的第一个客户端ID。包名当然是所有安置否则将不无令牌请求甚至工作正确。 2人还建议,应用程序需要签署这个工作,但谷歌文档中说,调试的关键应太,它没有任何意义,使人们签名的应用程序进行调试。

我一直在试图算出这个几个小时,但没有成功。可能是什么问题?请随时要求我可能会忘记把这里的更多信息。


解决方案

那么,这是很尴尬,但我想通了:

  GoogleSignInOptions GSO =新GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(AuthenticatedActivity.this.getResources()的getString(R.string.server_client_id))
                    .requestEmail()建立()。

我送它的资源ID,而不是递延字符串资源。

I'm using google sign-in services to authenticate users that use my app. I got it to work when I just requested email information

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestEmail().build();

Then, I figured out I also need to request ID token to be able to authenticate with my backend so I did:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(String.valueOf(R.string.server_client_id))
                    .requestEmail().build();

The problem is that it wouldn't let me log in after the changes. The status I keep getting each time I try to login is Status{statusCode=unknown status code: 12501, resolution=null}.

I've been searching around and I found this post that is pretty much about the same thing. However, I didn't make any of the mistakes named by the people who answered, the oAuth Client ID in my dev console is for web application: And R.string.server_client_id is the first client ID from the picture. the package names are of course correct in all placed otherwise it wouldn't even work without the token request. 2 people also suggested that the app needs to be signed for this to work, but googles documentation says that debug key should work too, and it doesn't make sense to make people sign the apps for debugging.

I've been trying to figure this out for hours but with no success. What could be the problem? Please feel free to request more information I might have forgotten to put here.

解决方案

Well, this is very embarrassing, but i figured it out:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(AuthenticatedActivity.this.getResources().getString(R.string.server_client_id))
                    .requestEmail().build();

I was sending it the resource ID instead of deferred string resource.

这篇关于错误12501认证与谷歌登入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆