Search Unity

Google Play Games Sign in: ERROR_NOT_AUTHORIZED [SOLVED]

Discussion in 'Android' started by Dakattack64, Sep 29, 2016.

  1. Dakattack64

    Dakattack64

    Joined:
    Sep 28, 2016
    Posts:
    3
    Hello all!

    I'm making a small game in unity and I'm trying to get my leaderboard to work correctly.
    So far I have followed this tutorial to the T and upon running the game on my tablet or phone I get an error in the log saying
    [Play Games Plugin DLL] DEBUG: Starting Auth Transition. Op: SIGN_IN status: ERROR_NOT_AUTHORIZED

    I've been googling for hours and have tried nearly everything I could. But none of the solutions seem to work, or they don't apply to my problem.

    When I start the game up, it will say "Connecting to... Google Play Games" but then it will display a loading circle for about a second and then it just returns to the game. No "Welcome User!" at the top. When I run a conditional statement on the success bool in the Social.localuser.Authenticate function it always returns false.

    Just to clarify:
    • I have created a keystore and key for the app, and I have entered the passwords correctly
    • I only have 1 google email, and it is the one connected to my developer account. Both of my devices are signed into google play using this email.
    • I have copied the "Get resources" information into the "Google Play Games -> Android Setup" window, named the file and hit "Setup".
    • I have linked/authorized the app and have an OAuth2.0 Client ID.
    • I have uploaded the most recent APK and have enabled alpha and beta testing (though the APK is in the production tab)
    • I have entered the bundle identifier in unity and made sure it matched the Package name in the developer console.
    This is how I start the platform (in the start function of my game manager). Looking at the log while the game is running shows that the play games platform successfully activates.

    Code (CSharp):
    1. // Create client configuration
    2.         PlayGamesClientConfiguration config = new
    3.             PlayGamesClientConfiguration.Builder()
    4.             .Build();
    5.  
    6.         // Enable debugging output (recommended)
    7.         PlayGamesPlatform.DebugLogEnabled = true;
    8.  
    9.         // Initialize and activate the platform
    10.         PlayGamesPlatform.InitializeInstance(config);
    11.         PlayGamesPlatform.Activate();
    12.  
    13.         Social.localUser.Authenticate((bool success) =>
    14.         {
    15.             if (success)
    16.             {
    17.                 Debug.Log("Login Success!");
    18.             }
    19.             else
    20.             {
    21.                 Debug.Log("Login Failed!");
    22.             }
    23.         });
    I'm not sure why I'm getting this error; am I missing any steps?
    Thanks in advance!
     

    Attached Files:

    mrsquare and Ortis like this.
  2. Dakattack64

    Dakattack64

    Joined:
    Sep 28, 2016
    Posts:
    3
    Nevermind! I fixed the issue.

    For those of you who may be having a similar issue, this is what I did:

    Visit the Google API Manager and click "Credentials" on the left side.
    If you linked your app correctly, you should see it listed here. Otherwise you need to ensure its linked here (there are a lot of YouTube videos covering this).

    Click on the pencil button on the right side of your app in the Credentials tab to edit the OAuth Client.
    You should see the "Signing-Certificate Fingerprint", but the code below it probably doesn't match the one in your keystore.

    In order to correct this, you need to find it by using the keytool.exe inside of your JDK directory. (Probably inside of C:\Program Files\Java\jdk1.8.0_60\bin)

    Inside your file explorer, click "File -> Open Command Prompt -> Open Command Prompt as Administrator"

    Here, you can run the keytool.exe in order to find your SHA-1 code. You may have noticed the keytool command listed above your SHA-1 code inside of the Google API Manager, but I'll post it here too.
    Type: keytool -exportcert -alias nameofyourkeystore -keystore C:\filelocationofyourkeystore\user.keystore -list -v

    Press enter and it should list your SHA-1 code, copy this and paste it into the field inside the Google API Manager. Then hit save and your app should be able to authenticate!

    Happy coding
     
    dabo248, vivekbharatha, rtejo and 5 others like this.
  3. socialtrens

    socialtrens

    Joined:
    Oct 23, 2017
    Posts:
    65
    Worked!
    Thanks.
     
  4. Javilingys

    Javilingys

    Joined:
    Nov 23, 2017
    Posts:
    7
  5. vivekbharatha

    vivekbharatha

    Joined:
    Nov 21, 2017
    Posts:
    1
    was about to die as I searched for hours, finally @Dakattack64 question and answer helped me :).
    Thanks a ton!
     
  6. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    +1 for OP's fix working, thanks so much!