2017-05-26 2 views
0

ゲームでGoogleゲームサービスを実装しましたが、ゲームサービスから返されたプレーヤーIDがハッキングされる可能性がありますか?ゲームサービスから返されたプレーヤーIDはハッキングされる可能性があります

このIDを使用して、データベースからプレーヤーデータを取得します。私はIDトークンを要求し、それをサーバーに送信してプレーヤのIDを検証し、それを検証することができることを認識しています。ただし、IDトークンをリクエストすると、ユーザーにアプリを「Google上にいるかどうかを知る」ことを許可するように求められますが、その許可を表示したくありません。

答えて

0

本当に使いたいのはサーバー認証コードです。フローは次のとおりです。

  1. ユーザーは通常どおりゲームでゲームにサインインします。 クライアント接続を構築するときは、ServerAuthCodeを要求してください。これは、 です。

    String webclientId = getString(R.string.webclient_id); 
    // Request authCode so we can send the code to the server. 
    GoogleSignInOptions options = new GoogleSignInOptions 
            .Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN) 
            .requestServerAuthCode(webclientId) 
            .build(); 
    
    
        mGoogleApiClient = new GoogleApiClient.Builder(this) 
          .addApi(Games.API) 
          .addApi(Auth.GOOGLE_SIGN_IN_API, options) 
          .addConnectionCallbacks(this) 
          .addOnConnectionFailedListener(this) 
          .build(); 
    
  2. サインインが完了すると、認証コードを取得し、サーバーに認証コードを送信します。

    @Override 
    protected void onActivityResult(int requestCode, int responseCode, 
              Intent intent) { 
    if (requestCode == RC_SIGN_IN) { 
        Log.d(TAG, "onActivityResult RC_SIGN_IN, responseCode=" 
          + responseCode + ", intent=" + intent); 
        GoogleSignInResult result = 
          Auth.GoogleSignInApi.getSignInResultFromIntent(intent); 
        if (result.isSuccess()) { 
         sendToServer(result.getSignInAccount().getServerAuthCode();); 
        } else { 
         showSignInError(result.getStatus().getStatusCode()); 
        } 
    
  3. サーバーで、そのユーザーのアクセストークンの認証コードを交換します。

     GoogleTokenResponse tokenResponse = 
          new GoogleAuthorizationCodeTokenRequest(
            HTTPTransport, 
            JacksonFactory.getDefaultInstance(), 
            "https://www.googleapis.com/oauth2/v4/token", 
            clientSecrets.getDetails().getClientId(), 
            clientSecrets.getDetails().getClientSecret(), 
            authCode, 
            "") 
            .execute(); 
    
  4. その後、サーバーは安全にユーザーのID を取得するためにアクセストークンを検証することができます。

    ApplicationVerifyResponse resp = gamesAPI.applications().verify 
         (applicationId).execute(); 
        Log.d(TAG, "The player id is " + resp.getPlayerId()); 
    

のGitHubでこれを行う方法を示すサンプルがあります:https://github.com/playgameservices/clientserverskeleton

は、
関連する問題