【问题标题】:Incorrect padding error with Google oAuth2 and Youtube APIGoogle oAuth2 和 Youtube API 的填充错误不正确
【发布时间】:2016-04-14 05:27:21
【问题描述】:

我一直在尝试使用 google oAuth2.0 对我的 django(python 3.4、django 1.9)应用程序进行身份验证,以使用 Youtube Data API v3。

我有一个用于服务器到服务器身份验证的 JSON 密钥(类型:服务帐户)。

错误源于下面的 build() 方法:

client_email = '***@***.iam.gserviceaccount.com'
with open('key.json', 'r+b', 0) as f:
    private_key = f.read()

credentials = SignedJwtAssertionCredentials(client_email, private_key,'https://www.googleapis.com/auth/youtube')
http_auth = credentials.authorize(Http())

service = build(str('youtube', 'v3', http=http_auth)
response = service.channels().list(part="id").execute()

我得到的错误是:

不正确的填充异常 /usr/lib/python3/dist-packages/Crypto/PublicKey/RSA.py 在 importKey,第 660 行

这是这一行:

der = binascii.a2b_base64(b('').join(lines[1:-1]))

我是 python 和 django 的新手,所以我的调试技能还没有达到标准。

【问题讨论】:

    标签: python django youtube-api google-oauth padding


    【解决方案1】:

    我没有找到这个问题的答案,但我发现您不能将服务帐户与 YouTube Data API v3 一起使用,这使得这个问题没有实际意义。

    来源:https://developers.google.com/youtube/v3/guides/authentication

    【讨论】:

      猜你喜欢
      • 2017-03-30
      • 2020-08-26
      • 2017-04-05
      • 1970-01-01
      • 2019-03-10
      • 2021-07-14
      • 2018-01-10
      • 1970-01-01
      相关资源
      最近更新 更多