ValueError:无法取消序列化键d

2024-04-24 05:47:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我在一个json文件中有一个密钥,我正在尝试将这个文件输入到googleplaystore的授权协议中。下面是我尝试过的:

    #authorization key

        config = {
            "type": "abc",
            "project_id": "abc",
            "private_key_id": "123",
            "private_key": "-----BEGIN PRIVATE KEY----[REDACTED]\n-----END PRIVATE KEY-----\n",
            "client_email": "abc@service-account.iam.gserviceaccount.com",
            "client_id": "345",
            "auth_uri": "https://accounts.google.com/o/oauth2/auth",
            "token_uri": "https://accounts.google.com/o/oauth2/token",
            "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/cert",
            "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/reporting%service-account.iam.gserviceaccount.com"
        }

    #Put auth key  into json file
    dbutils.fs.put("Temp/123.json",json.dumps(config))

    #Feed authorization key into Google Cloud Storage (GCS) account.
    path='Temp/123.json'
    storage_client = google.cloud.storage.Client.from_service_account_json(path)

但将引发以下错误:

ValueError: Could not unserialize key data. info, require=['client_email', 'token_uri'])

我做错什么了?你知道吗


Tags: keyhttpscomclienttokenauthidjson
1条回答
网友
1楼 · 发布于 2024-04-24 05:47:31

错误的原因似乎是私钥的格式错误。你知道吗

尝试使用另一个键;您可以在控制台中创建它,进入“IAM&;admin”->;“Service accounts”->;[account],然后编辑帐户并单击“create key”按钮。你知道吗

而且,似乎您正在使用cryptography包的old version。你知道吗

相关问题 更多 >