当我请求YouTube插入视频时,它会引发GoogleJsonResponseException,但没有JSON,因此我无法确定原因。我只能看到“ 401未经授权”,没有原因。
YouTube youtubeService = new YouTube.Builder(httpTransport, JSON_FACTORY, credential)
.setApplicationName(getYouTubeApplicationName()).build();
YouTube.Videos.Insert request = youtubeService.videos().insert(parts, video, mediaContent);
try {
Video response = request.execute();
return response.getId();
}
catch (GoogleJsonResponseException e) {
e.printStackTrace();
throw e;
}
如果我检查e,则发现e.detail为空。
google-api-client-1.30.9是否有问题?我希望能在OAuth 2.0 Playground中获得类似以下的内容:
{
"error": {
"message": "Unauthorized",
"code": 401,
"errors": [
{
"reason": "youtubeSignupRequired",
"locationType": "header",
"message": "Unauthorized",
"domain": "youtube.header",
"location": "Authorization"
}
]
}
}