Google Play游戏服务提供的OAuth令牌 [英] OAuth token with Google Play Game Services
本文介绍了Google Play游戏服务提供的OAuth令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过Google Play游戏服务获取用于登录用户的令牌?
Is there a way to get the token that was used to log in the user with Google Play Game Services?
我正在寻找类似的东西:
I'm looking for something like:
@Override
public void onSignInSucceeded() {
String email = getGamesClient().getCurrentAccountName();
String token = getGamesClient().getToken();
}
当用户联系我自己的服务器时,我需要使用它来对用户进行身份验证.
I need this to authenticate the user when they are contacting my own server.
推荐答案
这是我设法获取令牌的方式:
This is how I managed to get the token:
@Override
public void onSignInSucceeded() {
String email = getGamesClient().getCurrentAccountName();
String scopes = getScopes();
new registerBackground(getApplicationContext()).execute(email, scopes);
}
private class registerBackground extends AsyncTask<String, Void, Void> {
Context context;
registerBackground (Context context) {
this.context = context;
}
@Override
protected Void doInBackground(String... params) {
try {
String oAuthToken = GoogleAuthUtil.getToken(context, params[0], params[1]);
...
catch (Exception e) {
e.printStackTrace();
}
}
...
}
这篇关于Google Play游戏服务提供的OAuth令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文