【问题标题】:Status code 403 when trying to access DoubleClick Bid Manager Partner specific private buckets from google cloud java project尝试从 Google Cloud Java 项目访问 DoubleClick Bid Manager 合作伙伴特定的私有存储桶时出现状态代码 403
【发布时间】:2017-01-06 14:52:10
【问题描述】:

大家好, 目前的情况如下: 我目前有一个谷歌云项目。我用来登录 google cloud 项目的帐户也可以登录到 DoubleClick bid Manager 帐户。我的目标是使用 DoubleClick Bid Manager api 来检索 DBM 存储的某些存储桶,并将它们保存在我单独的谷歌云项目中。

到目前为止,我可以访问公共存储桶 (gdbm-public) 并提取和下载数据,但是当我尝试以相同的方式访问合作伙伴特定的存储桶时,即 (gdbm -201032-201843) 我得到一个状态码 403。

在阅读文档here 后,我发现我需要在 DBM 本身的 DBM 合作伙伴信息中添加一个 google 组。但是,当我尝试添加一个 google 组并保存更改时,我收到一条错误消息,指出无法保存更改。

这是我验证的地方:

return new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId("<service_account_i_cant_show_here>")
            .setServiceAccountScopes(Collections.singleton(StorageScopes.DEVSTORAGE_READ_ONLY))
            .setServiceAccountPrivateKeyFromP12File(new File("secret-privatekey.p12"))
            .build();

然后我尝试像这样访问存储桶:

    String bucketName = "gdbm-201032-201843";
    GoogleCredential credentials = getCredentials();
    Storage storage = new Storage(HTTP_TRANSPORT, JSON_FACTORY, credentials);

    Storage.Objects.List listObjects = storage.objects().list(bucketName);
    Objects objects;
    do {
        objects = listObjects.execute();
        for (StorageObject object : objects.getItems()) {
            System.out.println(object);
        }
        listObjects.setPageToken(objects.getNextPageToken());
    } while (null != objects.getNextPageToken());

更具体地说,listObjects.execute() 是抛出 403 的地方。

我要编辑的区域是合作伙伴本身的Log Read Google GroupLog Management Google Group

非常感谢任何帮助,谢谢!

【问题讨论】:

    标签: java google-cloud-storage google-cloud-platform double-click-advertising


    【解决方案1】:

    我想我有一个解决方案,我使用了与 here 不同的身份验证方式。 使用我在我的谷歌云项目客户端凭据中输入的链接类以及我登录谷歌云项目和 DBM 的用户。

    我还将范围更改为“https://www.googleapis.com/auth/cloud-platform”,但我不能 100% 确定这会对结果产生影响。

    代码示例:

    // Scopes for the OAuth token
    private static final Set<String> SCOPES =
            ImmutableSet.of("https://www.googleapis.com/auth/cloud-platform");
    
    public static Credential getUserCredential() throws Exception {
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
                JSON_FACTORY,
                new InputStreamReader(SecurityUtilities.class.
                        getResourceAsStream("/client_secret.json")));
        dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);
    
    // set up authorization code flow.
        GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
                HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
                .setDataStoreFactory(dataStoreFactory)
                .build();
        // authorize and get credentials.
        return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver())
                .authorize("<Personal user account>");
    

    所以我没有使用服务帐户,而是使用了个人帐户。

    【讨论】:

      猜你喜欢
      • 2014-09-22
      • 1970-01-01
      • 1970-01-01
      • 2018-01-05
      • 1970-01-01
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多