Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
YouTube Android SDK-凭据无效_Android_Google Api_Youtube Data Api - Fatal编程技术网

YouTube Android SDK-凭据无效

YouTube Android SDK-凭据无效,android,google-api,youtube-data-api,Android,Google Api,Youtube Data Api,由于以下单元测试,我收到了无效凭据错误: List<String> scopes = new ArrayList<String>(); scopes.add(YouTubeScopes.YOUTUBE_READONLY); try { GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(this, scopes); credential.setSelectedAc

由于以下单元测试,我收到了
无效凭据
错误:

List<String> scopes = new ArrayList<String>();
scopes.add(YouTubeScopes.YOUTUBE_READONLY);
try {
    GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(this, scopes);
    credential.setSelectedAccountName(account.name);

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

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

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

    for(Channel channel : channelsList) {
        // Do things
    }
} catch (UserRecoverableAuthIOException e) {
    e.printStackTrace();
    startActivityForResult(e.getIntent(), RESULT_REQUEST_AUTH);
} catch (IOException e) {
    e.printStackTrace();
}
我已将以下内容添加到我的Google API控制台:

  • Android应用程序的客户端ID
  • web应用程序的客户端ID
  • 浏览器应用程序的键
我还使用GoogleDriveSDK,它功能完美

在我的API列表中,我有:

  • 驱动程序接口
  • 驱动器SDK
  • Google+API
  • YouTube数据API v3

在我发放奖金的那一刻,我注意到有问题的应用程序也链接到了同事的谷歌账户。“Android应用程序客户端ID”的正确签名就在该帐户上。尽管如此,我在主帐户的密钥下也有正确的签名

但现在已解决。

看看这个
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
{
  "code" : 401,
  "errors" : [ {
    "domain" : "global",
    "location" : "Authorization",
    "locationType" : "header",
    "message" : "Invalid Credentials",
    "reason" : "authError"
  } ],
  "message" : "Invalid Credentials"
}