【问题标题】:GCP Cloud IAP OAuth2: Expected JWT to have 3 parts separated by a '.' but there are 2 partsGCP Cloud IAP OAuth2:预计 JWT 有 3 个部分,由“。”分隔但有两部分
【发布时间】:2020-01-31 16:24:46
【问题描述】:

我已在 Cloud IAP 背后保护了一个 Google App Engine 应用程序 - 端点现在需要按预期通过浏览器进行 Google 登录,并且一旦我添加了正确的权限就可以正常工作。但是,当我尝试使用 Postman / MS PowerApps OAuth2 身份验证时,出现以下错误:Expected JWT to have 3 parts by a '.'但有 2 个部分。

这是我的 Postman 设置:

Grant Type: Authorization Code

Callback URL: Authed Callback URL (added to list in console)

Auth URL: https://accounts.google.com/o/oauth2/auth

Access Token URL: https://accounts.google.com/o/oauth2/token

Client ID: IAP-App-Engine-app ClientID

Client Secret:  IAP-App-Engine-app Client Secret

Scope: openid email

Client Authentication: Send as Basic Auth Header

Cloud IAP OAuth2 有解决方案吗?

谢谢,

【问题讨论】:

    标签: google-cloud-platform oauth-2.0 jwt openid google-iap


    【解决方案1】:

    Google Cloud IAP 需要 OAuth 身份令牌。您正在尝试使用 OAuth 访问令牌。

    【讨论】:

    • 谢谢,我已经将 Postman 存储的 id_token 处理到了 Bearer Header 中,它工作得很好。你知道是否有自动的方法吗?
    • 我会在 Postman 上发布一个新问题。我已经回答了你关于 OAuth Tokens 的问题,但我没有使用 Postman 来解决这个问题。
    【解决方案2】:

    我在 Identity Platform 的文档中找到了答案。

    https://cloud.google.com/iap/docs/identity-howto

    IAP 还会在以下 HTTP 标头中将用户的身份传递给您的后端服务。这些标头应具有命名空间前缀 accounts.google.com。

    如果在请求令牌时将 Header Prefix 从默认的 Bearer 更改为 accounts.google.com,则后续对 IAP 安全资源的调用将成功。

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 2016-07-15
      • 2017-04-29
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多