Why is GetServerAuthCodeResult Deprecated? How can I do something equivalent in an Installed Application?

M1LKYW4Y :

Following this post: http://android-developers.blogspot.com/2016/01/play-games-permissions-are-changing-in.html I have obtained a single use authorization code for use on my backend server as follows:

import com.google.android.gms.games.Games;    
//later
Games.GetServerAuthCodeResult result = Games.getGamesServerAuthCode(gameHelper.getApiClient(), server_client_id).await(); 
if (result.getStatus().isSuccess()) {
    String authCode = result.getCode();
    // Send code to server...

This seems to works fine, but it presents a question:

1) getGamesServerAuthCode and GetServerAuthCodeResult are marked as deprecated. Why? Should I be using something else instead?

2) How would I do something equivalent in an non-Android installed Java application? I am able to obtain a token on the client application, but I also need to obtain a single use code to pass to my backend server like above. I can't find an equivalent function to get a Server Auth Code. (using com.google.api.client.extensions.java6.auth.oauth2)

I am basically trying to follow this flow: https://developers.google.com/games/services/web/serverlogin but in Java, NOT Javascript. I am attempting to do this in an Android app and a desktop Java app.

M1LKYW4Y :

There is finally a proper answer to part 1) of this question! In the release notes of gms 10.2.0 https://developers.google.com/android/guides/releases#february_2017_-_v102 the new method of obtaining a server code is described. A good example of how to do this is provided here: https://github.com/playgameservices/clientserverskeleton
I ended up updating Google's baseGameUtils to follow the example above.

Still not sure the proper way to do this for part 2) of the question, at the moment I am sending the token to the server which works but is probably unsafe.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=447985&siteId=1