Google 登录状态代码

Posted

技术标签:

【中文标题】Google 登录状态代码【英文标题】:Google SignIn Status Codes 【发布时间】:2019-01-28 08:00:33 【问题描述】:

这是我使用谷歌播放服务测试登录的全部代码 问题是

result.getStatus().getStatusCode()

return  codestatus ..... 12501

我不知道为什么?????

我在

上进行了连接

1 https://firebase.google.com

2https://play.google.com/apps/publish

public class MainActivity extends AppCompatActivity implements View.OnClickListener 

    private FirebaseAnalytics mFirebaseAnalytics;
    private FirebaseAuth mAuth;
    private int RC_SIGN_IN = 9003;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Obtain the FirebaseAnalytics instance.
        mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

        findViewById(R.id.sign_in_button).setOnClickListener(this);

        mAuth = FirebaseAuth.getInstance();


    

    @Override
    public void onClick(View view) 
        if (view.getId() == R.id.sign_in_button) 
            // start the asynchronous sign in flow
            startSignInIntent();
        
    

    private void startSignInIntent() 
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
                .requestServerAuthCode(getString(R.string.default_web_client_id))
                .build();
        Toast.makeText(this, getString(R.string.default_web_client_id), Toast.LENGTH_SHORT).show();
        GoogleSignInClient signInClient = GoogleSignIn.getClient(this,gso);
        Intent intent = signInClient.getSignInIntent();
        startActivityForResult(intent, 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);
            Toast.makeText(this, ""+result.getStatus().getStatusCode(), Toast.LENGTH_SHORT).show();
             if (result.isSuccess()) 
                // The signed in account is stored in the result.
                GoogleSignInAccount signedInAccount = result.getSignInAccount();
             else 
                String message = result.getStatus().getStatusMessage();
                if (message == null || message.isEmpty()) 
                    message = getString(R.string.signin_other_error);
                
                new AlertDialog.Builder(this).setMessage(message)
                        .setNeutralButton(android.R.string.ok, null).show();
            
        
    

【问题讨论】:

【参考方案1】:

来自官方文档

getStatusCode()

表示操作的状态。

退货

操作产生的状态代码。该值是 CommonStatusCodes 中的常量之一或特定于添加到 GoogleApiClient 的 API。

CommonStatusCodes

CommonStatusCodes
public class CommonStatusCodes extends Object
Known Direct Subclasses

通常在 API 界面之间共享的常见状态代码。

不断总结

int     API_NOT_CONNECTED                   The client attempted to call a method from an API that failed to connect.
int     CANCELED                            The result was canceled either due to client disconnect or cancel().
int     DEVELOPER_ERROR                     The application is misconfigured.
int     ERROR                               The operation failed with no more detailed information.
int     INTERNAL_ERROR                      An internal error occurred.
int     INTERRUPTED                         A blocking call was interrupted while waiting and did not run to completion.
int     INVALID_ACCOUNT                     The client attempted to connect to the service with an invalid account name specified.
int     NETWORK_ERROR                       A network error occurred.
int     RESOLUTION_REQUIRED                 Completing the operation requires some form of resolution.
int     SERVICE_DISABLED                    This constant was deprecated. This case handled during connection, not during API requests. No results should be returned with this status code.
int     SERVICE_VERSION_UPDATE_REQUIRED     This constant was deprecated. This case handled during connection, not during API requests. No results should be returned with this status code.
int     SIGN_IN_REQUIRED                    The client attempted to connect to the service but the user is not signed in.
int     SUCCESS                             The operation was successful.
int     SUCCESS_CACHE                       The operation was successful, but was used the device's cache.
int     TIMEOUT                             Timed out while awaiting the result.

【讨论】:

以上是关于Google 登录状态代码的主要内容,如果未能解决你的问题,请参考以下文章

状态码 12501 使用 google 登录进行身份验证

Unity Google Play 游戏插件:错误未授权代码 13

OpenId + 记住我/保持登录状态

在我的 GAE 应用程序中检查 Google 用户的 gtalk 好友在线状态,当他登录时

Google Play 游戏登录已取消,状态码为 SIGN_IN_REQUIRED

google chrome浏览器登录之后 以前没有登录状态下的收藏都不见了,急求各位给解决办法。