YouTube Android SDK - Invalid Credentials

I am getting error Invalid Credentials

as a result of the following unit test:

List<String> scopes = new ArrayList<String>();
try {
    GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(this, scopes);

    YouTube.Builder builder = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential).setApplicationName("TestApp");
    YouTube youtube =;

    YouTube.Channels.List channelRequest = youtube.channels().list("contentDetails");
    ChannelListResponse channelResult = channelRequest.execute();

    List<Channel> channelsList = channelResult.getItems();

    for(Channel channel : channelsList) {
        // Do things
} catch (UserRecoverableAuthIOException e) {
    startActivityForResult(e.getIntent(), RESULT_REQUEST_AUTH);
} catch (IOException e) {


When using this code, I first get UserRecoverableAuthIOException

as expected. After logging in, I get the following error: 401 Unauthorized
  "code" : 401,
  "errors" : [ {
    "domain" : "global",
    "location" : "Authorization",
    "locationType" : "header",
    "message" : "Invalid Credentials",
    "reason" : "authError"
  } ],
  "message" : "Invalid Credentials"


Added the following to the Google API Console:

  • Client ID for Android Application
  • Client ID for the web application
  • Browser Application Key

I am also using the Google Drive SDK which works great.

In my list of APIs, I am:

  • API driver
  • SDK driver
  • Google+ API
  • YouTube Data API v3

source to share

1 answer

The moment I turned on the bonus, I noticed that the app in question is also associated with a Google employee account. The correct signature for the "Android App Client ID" has been included in this account. Although, I also had the correct signature on the main account under the keys.

Resolved now though.



All Articles