title: Request is missing required authentication credential. Expected OAuth 2 access token
body: <p>we are trying to add Google Sign option to our project. We have successfully added this option to the site and to the ios application. But encountered difficulties adding to the android application. Using "Configure project" option in this page <a href="https://developers.google.com/identity/sign-in/android/start-integrating" rel="nofollow noreferrer">https://developers.google.com/identity/sign-in/android/start-integrating</a> I specify SHA1 of Andrid debug key (Gradle -> android -> signingReport) and package name (com.my.app). This form gives us WEB type client ID. I downloaded credentials.json and put it in the app folder of the project. I also found an android type client ID with specified SHA1 hash in the Google API Console, but I don't understand where to use it (if we use android type oauth client, we get an error "signInResult:failed code=10", so we should use web type client, and without such android client in the API console we get 12500 error and no token).</p>
  
  <p>Next we added a sample code to get token and pass it to our backend server according to this document <a href="https://developers.google.com/identity/sign-in/android/backend-auth" rel="nofollow noreferrer">https://developers.google.com/identity/sign-in/android/backend-auth</a>.</p>
  
  <pre><code>private void enterGoogle() {
          GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                  .requestEmail()
                  .requestIdToken("12345-OurWebTypeClient.apps.googleusercontent.com").build();
          mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
  
          Intent signInIntent = mGoogleSignInClient.getSignInIntent();
          startActivityForResult(signInIntent, RC_SIGN_IN);
      }
  
      private void handleSignInResult(Task&lt;GoogleSignInAccount&gt; completedTask) {
          try {
              GoogleSignInAccount account = completedTask.getResult(ApiException.class);
  
              String accessToken = account.getIdToken();
              authWithGoogleToken(accessToken);
  
          } catch (ApiException e) {
              // The ApiException status code indicates the detailed failure reason.
              // Please refer to the GoogleSignInStatusCodes class reference for more information.
              Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
  
          }
      }
  
      private void authWithGoogleToken(String accessToken) {
          if (accessToken == null)
              Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show();
          else
              RetrofitFactory.getInstance().authGoogle(accessToken)
                  .enqueue(new retrofit2.Callback&lt;JsonObject&gt;() {
                      @Override
                      public void onResponse(retrofit2.Call&lt;JsonObject&gt; call, retrofit2.Response&lt;JsonObject&gt; response) {
                          try {
                              if (response.isSuccessful() &amp;&amp; response.body() != null) {
                                  if (!response.body().has("error")) {
  
                                      Toast.makeText(MainActivity.this, "Success!", Toast.LENGTH_SHORT).show();
                                  } else {
                                      Toast.makeText(MainActivity.this, response.body().get("error").getAsString(), Toast.LENGTH_SHORT).show();
                                  }
                              }
                          } catch (Exception e) {
                              e.printStackTrace();
                              Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show();
                          }
                      }
  
                      @Override
                      public void onFailure(retrofit2.Call&lt;JsonObject&gt; call, Throwable t) {
                          Toast.makeText(context, "Error", Toast.LENGTH_SHORT).show();
                      }
                  });
      }
  </code></pre>
  
  <p>using this code, we get long token which starts from "eyJ". If we change a code little bit to use alternative methods:</p>
  
  <pre><code>.requestServerAuthCode("12345-OurWebTypeClient.apps.googleusercontent.com").build();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>String accessToken = completedTask.getResult().getServerAuthCode();
  </code></pre>
  
  <p>we get short token which starts from "4/0". We do not know what a difference between these 2 types of tokens from 2 methods of getting tokens, but on backend server we get one error for both types of tokens:</p>
  
  <pre><code>{
    "error": {
      "code": 401,
      "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
      "status": "UNAUTHENTICATED"
    }
  }
  </code></pre>
  
  <p>We do not have such error for token from iOS SDK for example. Please help to find out what is wrong with implementation of Google Sign In in the Android app?</p>