FHIR 沙箱临床医生登录问题 Epic

问题描述 投票:0回答:1

我在使用独立 OAuth 2.0 工作流程以临床医生身份登录 Epic FHIR 沙箱时遇到问题。每次我尝试使用测试用户凭据 FHIR 和密码 EpicFhir11! 执行 GET 请求时,都会遇到 404 未找到错误。

根据文档,我的应用程序应该链接(使用HTTP GET)到授权端点并附加特定的查询字符串参数,包括response_type、client_id、redirect_uri、scope和aud。我已经在我的代码中实现了这一点,并多次验证这些值是否正确。但是,我不断收到此错误。我们将非常感谢您的帮助。

import { useEffect } from 'react';
// import { oauth2 as SMART } from 'fhirclient';

import { useLocation, useNavigate } from 'react-router-dom';

import { physician_client_id, physician_redirect_uri, fhirServerBaseUrl } from '../secret';

const PhysicianLogin = () => {
    const navigate = useNavigate();
    const location = useLocation();
    const searchParams = new URLSearchParams(location.search);
    let code = null;
    code = searchParams.get('code');

    const audience = fhirServerBaseUrl + '/';

    const handleSubmit = (e) => {
        e.preventDefault();
        const authLink = `${fhirServerBaseUrl}/oauth2/authorize?response_type=code&redirect_uri=${physician_redirect_uri}&client_id=${physician_client_id}&scope=openid%20fhirUser&aud=${audience}`;
        window.location.href = authLink;
    };

    useEffect(() => {
        if (code) {
            console.log({
                code: code,
            });

            const params = new URLSearchParams();
            params.append('grant_type', 'authorization_code');
            params.append('code', code);
            params.append('redirect_uri', physician_redirect_uri);
            params.append('client_id', physician_client_id);
            params.append('state', '1234');

            let tokenUrl = fhirServerBaseUrl +'/oauth2/token';

            fetch(tokenUrl, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                    // Accept: 'application/x-www-form-urlencoded',
                },
                body: params,
                // body: JSON.stringify({
                //  grant_type: 'authorization_code',
                //  code: code,
                //  redirect_uri: redirect,
                //  client_id: clientId,
                // }),
            })
                .then((response) => response.json())
                .then((data) => {
                    if (data.access_token) {
                        localStorage.setItem('accessToken', data.access_token);
                        localStorage.setItem('patient', data.patient);
                        navigate('/physician');
                        // fetch(`https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/DSTU2/Patient/${this.patient}`)
                    }
                    console.log({
                        tokenData: data,
                    });
                });
        } else {
            console.log('no code');
        }
    }, []);
    return (
        <section>
            <div className='login-container'>
                <form action='' className='login-form' onSubmit={handleSubmit}>
                    <div className='form-control'>
                        <input
                            type='submit'
                            value='Login with FHIR-epic'
                            className='btn-submit'
                        />
                        
                        >
                            Sign in with FHIR epic
                        </a> */}
                    </div>
                </form>
            </div>
        </section>
    );
};

export default PhysicianLogin;

我预计能够使用临床医生测试帐户登录 Epic 沙箱。我确保非生产的客户端 ID、重定向 URI 和 FHIR 服务器基本 URL 均准确。我还检查了该应用程序的目标受众是临床医生,甚至尝试使用不同的测试用户 (FHIRTWO) 登录。我已联系 [电子邮件受保护],他们指示我联系供应商服务。如果可以的话,我希望避免与供应商服务相关的任何费用。

authentication oauth-2.0 hl7-fhir epic smart-on-fhir
1个回答
0
投票

您似乎甚至没有进入用户登录屏幕,因此您的初次通话肯定出了问题。有几件事可以尝试:

  1. 确保您的重定向 URI(精确到大写、斜杠等)与应用列表中的重定向 URI 之一完全匹配。
  2. 确保您的应用程序以及对其所做的任何更改已等待足够长的时间(最多 12 小时)才能同步到沙盒环境。
  3. 看来你的
    audience
    不正确。您将其设置为
    fhirServerBaseUrl + '/'
    ,这将使其成为
    https://fhir.epic.com/interconnect-fhir-oauth/
    。它应该是
    https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4
    (或者您使用的 FHIR 版本,如果不是 R4)。

如果这些不起作用,请澄清您要设置的内容

fhirServerBaseUrl

© www.soinside.com 2019 - 2024. All rights reserved.