首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >无法从epic fhir auth服务器获得一个令牌

无法从epic fhir auth服务器获得一个令牌
EN

Stack Overflow用户
提问于 2022-03-02 08:13:48
回答 1查看 752关注 0票数 1

我不会从我的史诗应用程序中得到一个象征性的东西。

我打电话给我的应用程序(PFI_app,非prod)。来自浏览器脚本的客户端id: my_client_id):

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
FHIR.oauth2.authorize({
    'client_id':[my_client_id],
    'scope':'openid, fhirUser,PATIENT.READ, PATIENT.SEARCH, OBSERVATION.READ, OBSERVATION.SEARCH',
    'redirect_uri':[my_redirect_uri],
    'state':'abc123',
    'aud':'https://fhir.epic.com/interconnect-fhir-oauth/api/fhir/r4'
});

提示我登录signin.epic.com,并使用凭据FHIR (用户名)和EpicFhir11!(密码),这是我从这个页面获得的:https://fhir.epic.com/Documentation?docId=testpatients

在重定向url页面上,我使用以下方法获取访问令牌:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
FHIR.oauth2.ready()
      .then(function(client){
        myapp.smart = client
        console.log(client);
      })

但是,我一直收到以下错误消息:

加载资源失败:服务器响应状态为400 (坏请求) app.html:39 https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token

我收到另一条消息说: URL:https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token unauthorized_client

这使我相信,我登录的是一个不适当的用户谁没有授权。

最终,我没有得到任何象征性的东西。知道为什么吗?是因为我使用了不正确的登录凭据,因此该用户无法获得令牌。

另外,我使用的是fhir-client.js -不是,fhir-client-v2.js,这是个问题吗?

更新:

所以我就等着,象征性的问题解决了。也许我在fhir.epic.com修改了史诗般的fhir应用程序信息之后,不得不等待一段时间。我把“应用受众”从病人变成了“临床医生和管理用户”。在我写这篇文章之前,当我作为管理员被提示时,我已经登录到epic上了很多个小时,但是我想不出我修改了什么代码。我只是在等。

现在,我剩下的最后一个问题是,当我尝试用下面的代码从沙箱中搜索病人时:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
var obs = await fetch(myapp.smart["state"]["serverUrl"]+"/Patient?address=123%20Main%20St.&address-city=Madison&address-postalcode=53703&address-state=Wisconsin&family=Mychart&gender=Female&given=Allison&telecom=608-123-4567",{
          headers:{
            "Accept":"application/json+fhir",
            "Authorization":"Bearer"+myapp.smart["state"]["tokenResponse"]["access_token"]
          }
        }).then(function(data){
          return data;
        });
        
        var response = await obs.json();

        console.log( response );

我收到另一条“未经授权的消息”:

加载资源失败:服务器响应状态为401 (未经授权) https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/Patient?address=123%20Main%20St.&address-city=Madison&address-postalcode=53703&address-state=Wisconsin&family=Mychart&gender=Female&given=Allison&telecom=608-123-4567

这就是构造对Patient.search资源的调用的语法:

https://fhir.epic.com/Sandbox?api=932

知道我为什么未经授权打这个电话吗?,我是使用面向提供者的应用程序用户凭据登录的,这里列出了:https://fhir.epic.com/Documentation?docId=testpatients (用户名: FHIR)

更新:

因此,我更改了FHIR.oauth2.readed调用,以包含该请求,它就成功了。我不知道为什么不能将所提供的令牌作为Bearer令牌包含在提取中,但以下操作有效:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
var req = "/Patient?address=123%20Main%20St.&address-city=Madison&address-postalcode=53703&address-state=Wisconsin&family=Mychart&gender=Female&given=Allison&telecom=608-123-4567"

FHIR.oauth2.ready( client => client.request(req) ).then(function(output){
        console.log(output); /* should include search results for the patient */ 
});

谢谢你的帮助

EN

回答 1

Stack Overflow用户

发布于 2022-03-03 12:13:41

总之,我更改了FHIR.oauth2.备好的调用以包含请求,它成功了:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
var req = "/Patient?address=123%20Main%20St.&address-city=Madison&address-postalcode=53703&address-state=Wisconsin&family=Mychart&gender=Female&given=Allison&telecom=608-123-4567"

FHIR.oauth2.ready( client => client.request(req) ).then(function(output){
        console.log(output); /* should include search results for the patient */ 
});

此外,我不得不等待一段时间,可能是因为我在史诗般的fhir应用程序中做了一些修改。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71325858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文