title: show user's YouTube data like user's liked videos and subscriptions in android app
body: <p><strong>What I am trying to implement:</strong></p>
  <p>I am trying to develop an Android app which signs user in using Google SignIn and then asks the user to grant Youtube's scope access so that my app could access and get user's subscriptions and other data provided by Youtube Data API. I have setup Google Developer's Console project and the user is being signed in but when I request addition scope of Youtube the screen appears after sign in and it keeps loading. I have enabled Youtube Data API v3 also and added the scopes to OAuth Consent in Developer Console. Here is the code. It's a native Java Code written in Android Studio. Moreover, I have searched all over the internet but I couldn't find any solution or maybe I could not understand.</p>
  <pre><code>public class MainActivity extends AppCompatActivity{
  
  private static final String TAG = &quot;tagg&quot;;
  
  // Bundle key for account object
  private static final String KEY_ACCOUNT = &quot;key_account&quot;;
  
  // Request codes
  private static final int RC_SIGN_IN = 9001;
  private static final int RC_RECOVERABLE = 9002;
  private static final int RC_REQUEST_PERMISSION_SUCCESS_CONTINUE_FILE_CREATION = 0011;
  
  private Account mAccount;
  
  // Global instance of the HTTP transport
  private static final HttpTransport HTTP_TRANSPORT = AndroidHttp.newCompatibleTransport();
  
  // Global instance of the JSON factory
  private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
  
  private GoogleSignInClient mGoogleSignInClient;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      GoogleSignInOptions gso = new GoogleSignInOptions
              .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
              //.requestScopes(new Scope(YOUTUBE_SCOPE))
              .requestEmail()
              .requestIdToken(&quot;992631576722-dkn5pp9du25idplr9ll0vkub8pa1sq95.apps.googleusercontent.com&quot;)
              .build();
  
      mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
  
      findViewById(R.id.signinbtn).setOnClickListener(v -&gt; {
          signIn();
      });
  
      findViewById(R.id.logout).setOnClickListener(v -&gt; {
          mGoogleSignInClient.revokeAccess();
      });
  }
  
  @Override
  public void onStart() {
      super.onStart();
  
      GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
      if (account==null) Toast.makeText(this,&quot;Not Signed&quot;,Toast.LENGTH_SHORT).show();
  
  }
  private void signIn() {
      Intent signInIntent = mGoogleSignInClient.getSignInIntent();
      startActivityForResult(signInIntent, RC_SIGN_IN);
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
      if (requestCode == RC_SIGN_IN) {
          Task&lt;GoogleSignInAccount&gt; task = GoogleSignIn.getSignedInAccountFromIntent(data);
          if (task==null) Toast.makeText(getApplicationContext(),&quot;Null task&quot;,Toast.LENGTH_SHORT)
          .show();
          else {
              if (!GoogleSignIn.hasPermissions(
                      task.getResult(),new Scope(YouTubeScopes.YOUTUBE_FORCE_SSL))) {
                      GoogleSignIn.requestPermissions(
                          MainActivity.this,
                          RC_REQUEST_PERMISSION_SUCCESS_CONTINUE_FILE_CREATION,
                          task.getResult(),
                              new Scope(YouTubeScopes.YOUTUBE_FORCE_SSL));
              } else {
              //task.addOnSuccessListener(googleSignInAccount -&gt; Log.d(TAG, &quot;onSuccess: task 
          successful&quot;))
                //   .addOnFailureListener(e -&gt; Log.d(TAG, &quot;onFailure: &quot;+e.getLocalizedMessage()));
                  handleSignInResult(task);
              new Thread(() -&gt; {
                  try {
                      Log.d(TAG, &quot;the token: &quot;+GoogleAuthUtil
                              .getToken(getApplicationContext(),
                                      task.getResult().getAccount(),YouTubeScopes.YOUTUBE_READONLY));
                  } catch (IOException | GoogleAuthException e) {
                      Log.d(TAG, &quot;token failed: &quot;+e.getLocalizedMessage());
                  }
              }).start();
              //}
          }
      }
  }
  
  
  
  private void handleSignInResult(@NonNull Task&lt;GoogleSignInAccount&gt; completedTask) {
      Log.d(TAG, &quot;handleSignInResult:&quot; + completedTask.isSuccessful());
  
      try {
          GoogleSignInAccount account = completedTask.getResult(ApiException.class);
          // Store the account from the result
          mAccount = account.getAccount();
          account.requestExtraScopes(new Scope(YouTubeScopes.YOUTUBE_READONLY));
          Log.d(TAG, &quot;id token: &quot;+account.getIdToken());
          // Asynchronously access the Youtube API for the account
          new GetSubscriptionTask().execute(mAccount);
  
      } catch (ApiException e) {
          Log.d(TAG, &quot;handleSignInResult:error&quot;+e.getStatusCode());
  
          // Clear the local account
          mAccount = null;
      }
  }
  
  /**
   * AsyncTask that uses the credentials from Google Sign In to access Youtube subscription API.
   */
  private class GetSubscriptionTask extends AsyncTask&lt;Account, Void, List&lt;Subscription&gt;&gt; {
  
      @Override
      protected List&lt;Subscription&gt; doInBackground(Account... params) {
          Log.d(TAG, &quot;doInBackground: &quot;);
          try {
              GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(
                      MainActivity.this,
                      Collections.singleton(YouTubeScopes.YOUTUBE_READONLY));
              credential.setSelectedAccount(params[0]);
  
              YouTube youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
                      .setApplicationName(&quot;Get User's Own Channel&quot;)
                      .build();
  
              ChannelListResponse channelListResponse = youtube
                      .channels()
                      .list(&quot;id,contentDetails&quot;)
                      .setMine(true)
                      .setFields(&quot;items(contentDetails/relatedPlaylists/uploads,id)&quot;)
                      .execute();
  
              // get signed user channel id:
              Channel myChannel = channelListResponse.getItems().get(0);
              String channelId = myChannel.getId(); // this is user's channel ID
  
              Log.d(TAG, &quot;my youtube channel id: &quot; + channelId);
  
              SubscriptionListResponse connectionsResponse = youtube
                      .subscriptions()
                      .list(&quot;snippet&quot;)
                      .setChannelId(channelId)
                      .execute();
  
              return connectionsResponse.getItems();
          } catch (UserRecoverableAuthIOException userRecoverableException) {
              Log.d(TAG, &quot;getSubscription:recoverable exception&quot;+userRecoverableException.getLocalizedMessage());
              startActivityForResult(userRecoverableException.getIntent(), RC_RECOVERABLE);
          } catch (IOException e) {
              Log.d(TAG, &quot;getSubscription:exception&quot;+e.getLocalizedMessage());
          }
  
          return null;
      }
  
      @Override
      protected void onPostExecute(List&lt;Subscription&gt; subscriptions) {
  
          if (subscriptions != null) {
              Log.d(TAG, &quot;subscriptions : size=&quot; + subscriptions.size());
              for (Subscription subscription : subscriptions) {
                  Log.v(TAG, &quot;subscription : &quot; + subscription.getId());
              }
          } else {
              Log.d(TAG, &quot;subscriptions: null&quot;);
          }
      }
  }
  </code></pre>
  <p>There is a sign in and sign out button on the layout.</p>