Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I create multiple OAuth 2.0 client IDs for the same package name?

In the tutorial here, it's stated that it's perfectly possible to use two OAuth 2.0 client IDs for the same package name.

You should create two client IDs, one with the release certificate fingerprint and another with the debug certificate fingerprint. Make sure to use the same package name for both. This allows Play Games services to recognize calls from your linked APKs that are signed with either certificate

So I follow the tutorial in the link above: first go to Game Service in Developer Console, Add a new Game. Then I add a Linked app with this Game, it requires me to create an OAuth 2.0 client ID. After creating the first client ID with my release key's SHA1 , I cannot find any button to create another client ID. So I go to Cloud Developer Console and found out that I can create a second client ID here under APIs & auth-> Credentials. I use my debug.keystore 's SHA1 for this second client ID. Then I compile and test my example game with both the debug key and the release key.

However, after have run the app and attempted to sign in, the result is that only the app using the release key (using the first client ID) is accepted, while the app using the debug key (using the second client ID) is not accepted.

Then I try to delete my release key's client ID in the Cloud Developer Console (so that the debug key's client ID remains as the only client ID there) and test my app again. This time, the app using the debug key is accepted, and the app using the release key is of course not accepted.

So does this mean that I cannot create multiple OAuth 2.0 client IDs for the same package name?

like image 573
Hải Phong Avatar asked Feb 20 '14 05:02

Hải Phong


2 Answers

As explained in the red warning note in the same tutorial:

Warning: Do not create new client IDs for your game from the Google Developers Console. If you do so, Play Games services will not associate your game settings with the client ID, and this could cause errors during gameplay.

Instead, in the Game Service part of the Developer Console, go to 2. Linked Apps and select Link another app and follow the directions there, giving it a name such as 'Game Name Debug' and using your debug key SHA1 (every other field should be the same as your release app).

like image 160
ianhanniballake Avatar answered Sep 28 '22 07:09

ianhanniballake


An additional note:

You have to specify a different package in Google Play services when linking the second app. If you do not specify a different package, then the "Authorize" section will not appear. Then, in the authorize section you can specify the original package (if you want to use only one package for not changing manifests). Is a bit cumbersome and weird but it works.

like image 27
Dredok Avatar answered Sep 28 '22 07:09

Dredok