【问题标题】:I need to implement OAuth 2.0 JWT Bearer Flow for Server-to-Server Integration using a community user我需要使用社区用户实施 OAuth 2.0 JWT Bearer Flow 以进行服务器到服务器集成
【发布时间】:2022-06-11 02:20:17
【问题描述】:

我需要能够使用 JWT 为社区用户获取访问令牌。我的最终目标是使用此访问令牌将其与 frontdoor.jsp 一起使用

这是我的要求:

 curl --location --request POST 'https://login.salesforce.com/services/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: BrowserId=P8QALYKvEeyLlh_jJBTAjg; CookieConsentPolicy=0:0; LSKey-c$CookieConsentPolicy=0:0' \
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer' \
--data-urlencode 'assertion=my-jwt'

这是我的 JWT 的有效负载:

{
"iss" : <connected-app-consumer-key>,
"sub" : "someCommunityUser@gmail.com",
"aud" : "https://my-community.force.com/customers",
"exp" : "1654818853"
}

我收到了这个错误:

Postman response

【问题讨论】:

    标签: jwt salesforce salesforce-communities


    【解决方案1】:

    您遇到的问题是因为您使用的令牌端点是供内部用户使用的。如果您想对体验用户(社区用户)进行身份验证,您需要使用不同的令牌端点,而不是 https://login.salesforce.com/services/oauth2/token

    令牌端点应如下所示

    https://your-custom-domain.eu27.force.com/partners/services/oauth2/token

    • your-experiece-domain.eu27.force.com 是为您的体验站点分配的域(如果您没有设置自定义域)。
    • 合作伙伴是您的体验网站的路径(如果有)
    • /service/oauth2/token 是获取访问令牌的经典端点

    在此之后您可以继续获得“用户尚未批准此消费者”,如果是的话

    1. 转到您连接的应用程序 -> 管理 -> 编辑策略
    2. 将允许的用户设置为“管理员批准的用户是预先授权的”
    3. 点击保存
    4. 向下滚动到“配置文件”或“权限集”
    5. 点击“管理配置文件”或“管理权限集”
    6. 添加您希望获得预授权的合作伙伴用户的个人资料或您希望使用的权限集以授予对体验站点的访问权限。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-25
      • 2014-02-05
      • 1970-01-01
      • 2010-10-21
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多