gpt4 book ai didi

android - Google Firebase 登录给出状态 12501(不工作),在发布构建变体和 jks SHA

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:48:04 27 4
gpt4 key购买 nike

我知道这个问题已经被很多人问过并且已经得到了回答。

那么,为什么我又要问这个问题呢?因为我尝试了这些解决方案,而且我确实遵循了 Google 文档、教程和 youtube。仍然没有运气。

好吧,这就是我在我的项目中所做的。

项目:GoogleSignIn

dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}

Gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {
signingConfigs {
config {
keyAlias 'alias'
keyPassword 'keypass'
storeFile file('/home/reoxey/path/to/jks')
storePassword 'storepass'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "reoxey.com.googlesignin"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
signingConfig signingConfigs.config
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.google.android.gms:play-services-auth:9.8.0'
testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

登录 Activity .java

gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.web_client_key))
.requestEmail()
.build();

mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();

findViewById(R.id.sign_in_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN){
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()){
Toast.makeText(getApplicationContext(),"Nailed it",Toast.LENGTH_LONG).show();
}else {
Snackbar.make(mLoginFormView,result.getStatus().toString(),Snackbar.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(),"Messed",Toast.LENGTH_LONG).show();

}
}
}

字符串.xml

<string name="web_client_key">123456789-clientwebapplication.apps.googleusercontent.com</string>

manifest 中没有特殊的配置,我相信我没有遗漏任何东西。

google-services.json

{
"project_info": {
"project_number": "{numeric-id}",
"firebase_url": "https://project--123456789.firebaseio.com",
"project_id": "project--123456789",
"storage_bucket": "project--123456789.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:{numeric-id}:android:sfdjgsdkdfgsfs",
"android_client_info": {
"package_name": "reoxey.com.googlesignin"
}
},
"oauth_client": [
{
"client_id": "{numeric-id}-androidkey.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "reoxey.com.googlesignin",
"certificate_hash": "{sha1-from-jks-file}"
}
},
{
"client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "{android-key}"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}

好的,现在是 Firebase 控制台。

  • 使用包名创建项目
  • 添加了从 jks 文件生成的 sha1 指纹
  • 为 google 登录启用身份验证

我想就是这样,希望我提供了一切,
那么我在这里缺少什么。

当我点击 google sign 时,它给我一个带有 12501 状态代码的错误。我不知道这里出了什么问题。任何人?

提前致谢。

最佳答案

构建 GoogleSignInOptions 时,您使用字符串资源 web_client_key。出于安全原因,您没有发布真实 key ,而是使用了示例值 123456789-clientwebapplication.apps.googleusercontent.com。

该示例值未出现在发布的 google-services.json 中,因此我无法将其与那里的值相匹配。该值应该是此 block 中定义的 client_id:

{
"client_id": "{numeric-id}-webapplication.apps.googleusercontent.com",
"client_type": 3
}

这是你使用的值吗?

获取网络客户端ID的conventional way是使用字符串资源R.string.default_web_client_id,它是由Google Services Gradle Plugingoogle-services.json生成的。有没有理由你不能这样做并且必须定义你自己的字符串资源?您是否尝试过使用 default_web_client_id

关于android - Google Firebase 登录给出状态 12501(不工作),在发布构建变体和 jks SHA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40561015/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com