【问题标题】:EPIC FHIR SMART Backend Services: { "error": "invalid_client", "error_description": null }EPIC FHIR SMART 后端服务:{“error”:“invalid_client”,“error_description”:null }
【发布时间】:2021-09-09 16:07:20
【问题描述】:

我正在尝试实现 EPIC FHIR SMART Backend Services (Backend OAuth 2.0) on go 编程语言。

我已经创建了我的开发帐户,在那里上传了公钥,并选择了 backend system 作为应用程序受众。

我很确定我的 jwt 令牌是正确的。我在 jwt.io 上检查过,签名是正确的。但是,我总是收到此错误:

{ "error": "invalid_client", "error_description": null }

我也尝试了其他可能的解决方案,例如:

  • 确保喷气式飞机索赔中的到期日期低于 5 分钟
  • 将有效负载放置在具有正确内容类型的正文中,即application/x-www-form-urlencoded
  • 确保使用沙盒client_id
  • 使用正确的 jwt 登录方法 (RS384)

我应该怎么做才能解决这个问题?

顺便说一句,我还看到several discussions on the google groups 说在开发帐户创建后等待一两天是值得的。

下面是我的代码。感谢您的帮助!

var (
    oauth2TokenUrl  = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token"
    sandboxClientID = "..."
    privateKey      = "..."
)

// load private key
signKey, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(privateKey))
So(err, ShouldBeNil)

// construct jwt claims
now := time.Now()
claims := jwt.MapClaims{
    "iss": sandboxClientID,
    "sub": sandboxClientID,
    "aud": oauth2TokenUrl,
    "jti": uuid.New().String(),             // fill with reference id
    "exp": now.Add(1 * time.Minute).Unix(), // cannot be more than 5 minutes!
}
log.Info("  => claims:", utility.ToJsonString(claims))

// generate signed token using private key with RS384 algorithm
alg := jwt.SigningMethodRS384
signedToken, err := jwt.NewWithClaims(alg, claims).SignedString(signKey)
So(err, ShouldBeNil)
log.Info("  => signed token", signedToken)

// prepare api call payload
payload := map[string]string{
    "grant_type":            "client_credentials",
    "client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
    "client_assertion":      signedToken,
}

// dispatch the api call
req := resty.New().
    R().
    EnableTrace().
    SetFormData(payload)
res, err := req.Post(oauth2TokenUrl)
So(err, ShouldBeNil)
log.Info("  => response status:", res.StatusCode())
log.Info("  => response header:", res.Header())
log.Info("  => response body:", string(res.Body()))

// parse response
resBody := make(map[string]interface{})
err = json.Unmarshal(res.Body(), &resBody)
So(err, ShouldBeNil)

【问题讨论】:

    标签: go hl7-fhir


    【解决方案1】:

    太棒了,我现在开始工作了。

    解决方案只是等待!这很令人困惑,因为我在文档上找不到任何关于此的解释,而且错误消息也不是用户友好的。

    总之,在创建开发应用程序并将公钥上传到那里之后,我们必须等待几个小时/几天,然后凭证才能最终可用。

    等待部分适用于 open epicapp orchard 开发者帐户。

    【讨论】:

    • 这可能是什么?我们的应用程序在商店里已经有一段时间了,但我仍然遇到同样的错误。
    • 您选择的受众群体是?如果是后端系统,那么您需要在那里上传公钥
    【解决方案2】:

    Epic 似乎有某种每天运行一次的同步机制。因此,在创建帐户后等待是唯一的解决方案。另请注意,在Endpoint URI更改后的应用设置中,您还需要等待一段时间。

    redirect_uri 参数设置为localhost:3000 之类的值时,也会出现错误{ "error": "invalid_client", "error_description": null }

    【讨论】:

      猜你喜欢
      • 2013-11-16
      • 2023-03-30
      • 2020-04-20
      • 2019-11-12
      • 1970-01-01
      • 2019-05-21
      • 2019-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多