2016-03-10 32 views
0

我试图通过YouTube数据API V3代表'[email protected]'将视频上传到YouTube帐户,并且我收到'access_denied'错误。 根据谷歌文档:通过服务器端数据代表用户将视频上传到YouTube使用API​​ V3

  1. 我打开使用谷歌管理员帐户“[email protected]”服务帐户并完成以下步骤:www.developers.google.com/identity/protocols/OAuth2ServiceAccount# delegatingauthority。

  2. 我以'[email protected]'身份登录并授予我在步骤1中创建的'[email protected]'服务帐户的权限。 (位于www.console.developers.google.com/permissions/ projectpermissions的权限“标签=> '添加成员')add member

这是我的请求(JAVA):

youtube = new YouTube.Builder(
      GoogleAuthImpl.HTTP_TRANSPORT, 
      GoogleAuthImpl.JSON_FACTORY, 
      new GoogleCredential.Builder() 
        .setTransport(HTTP_TRANSPORT) 
        .setJsonFactory(JSON_FACTORY) 
        .setServiceAccountId("[email protected]") 
        .setServiceAccountPrivateKeyFromP12File(new File("my-service-account.p12")) 
        .setServiceAccountScopes(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN)) 
        .setServiceAccountUser("[email protected]") 
        .build() 
    ) 
      .setApplicationName("My App") 
      .build(); 

而这是响应:com.google.api.client.auth.oauth2.TokenResponseException: 403 Forbidden { "error" : "access_denied", "error_description" : "Requested client not authorized." } at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105) at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287) at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307) at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:384) at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489) at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)

是否可以代表用户上传视频?难道我做错了什么?

另外,我找到了一个指向YouTube数据API的链接--Oauth 2.0流程,可能表明此操作(通过服务帐户代表另一用户导出到YouTube)不受支持:www.developers.google.com/ youtube/v3/guides/authentication#OAuth2_Flows

希望你的回应多多!

回答

0

YouTube API不支持您需要使用Oauth2的服务帐户。

+0

@DalmTo你可以请分享任何资源来引用服务器使用Oauth2更新YouTube视频标题 –

+0

我没有java的力量抱歉,我多年前用c#做了它。 – DaImTo

相关问题