title: Get Access Token From Google Drive API by GoogleAuthUtil in Android
body: <p>I got a weird problem in using GoogleAuthUtil when accessing the Google Drive API.</p>
  
  <p>Following is my code,</p>
  
  <pre><code>    @Override
      protected String doInBackground(String... params){
          String accountName = params[0];
          //String scopes = "oauth2:profile email"; // This can work !
          String scopes = "oauth2:server:client_id:7666010xxxxx-dm0d37oxxxxxxxih8k5sm5g7tajetubk.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/drive";
          String token = null;
          try{
              token = GoogleAuthUtil.getToken(getApplicationContext(), accountName, scopes);
          }
          catch (IOException e){
              Log.e(excpTAG, "IO Exception: " + e.getMessage());
          }
          catch (UserRecoverableAuthException e){
              startActivityForResult(e.getIntent(), REQ_SIGN_IN_REQUIRED);
          }
          catch (GoogleAuthException e)
          {
              Log.e(excpTAG, "GoogleAuthException: " + e.getMessage());
          }
          return token;
      }
  </code></pre>
  
  <p>In my empirical test, I can acquire the access token for user's Google profile/email by setting the scopes as</p>
  
  <pre><code>String scopes = "oauth2:profile email";
  </code></pre>
  
  <p>However, when I want to access user's Google Drive, I followed the instructions in development document</p>
  
  <p><a href="https://developers.google.com/accounts/docs/CrossClientAuth" rel="nofollow">https://developers.google.com/accounts/docs/CrossClientAuth</a></p>
  
  <p>and set the scopes as</p>
  
  <pre><code>String scopes = "oauth2:server:client_id:766601xxxxxx-dm0dxxxxxxxxxxxxxxxx7tajetubk.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/drive";
  </code></pre>
  
  <p>When the app executed, the Log cat in Android-Studio always mentioned that the exception event GoogleAuthException occured, and the event message is 'Unknown'.</p>
  
  <p>What is the correct way to get the access token for Google Drive in Android? Thanks a lot.</p>