Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try it with an AsyncTask like this:</p> <pre><code> AsyncTask&lt;Void, Void, String&gt; task = new AsyncTask&lt;Void, Void, String&gt;() { @Override protected String doInBackground(Void... params) { String token = null; try { token = GoogleAuthUtil.getToken( MainActivity.this, mGoogleApiClient.getAccountName(), "oauth2:" + SCOPES); } catch (IOException transientEx) { // Network or server error, try later Log.e(TAG, transientEx.toString()); } catch (UserRecoverableAuthException e) { // Recover (with e.getIntent()) Log.e(TAG, e.toString()); Intent recover = e.getIntent(); startActivityForResult(recover, REQUEST_CODE_TOKEN_AUTH); } catch (GoogleAuthException authEx) { // The call is not ever expected to succeed // assuming you have already verified that // Google Play services is installed. Log.e(TAG, authEx.toString()); } return token; } @Override protected void onPostExecute(String token) { Log.i(TAG, "Access token retrieved:" + token); } }; task.execute(); </code></pre> <p><code>SCOPES</code> is a space separated list of OAuth 2.0 scope strings. For example <code>SCOPES</code> could be defined as:</p> <pre><code>public static final String SCOPES = "https://www.googleapis.com/auth/plus.login " + "https://www.googleapis.com/auth/drive.file"; </code></pre> <p>These represent the permissions that your app is requesting from the user. The scopes requested in this example are documented here:</p> <ul> <li><a href="https://developers.google.com/+/api/oauth" rel="noreferrer">https://developers.google.com/+/api/oauth</a></li> <li><a href="https://developers.google.com/drive/android/files" rel="noreferrer">https://developers.google.com/drive/android/files</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload