Authentication/API Token retrieval for eClinicalWorks, other FHIR endpoints

Just curious about various methods to authenticate with FHIR through various EMR vendors. I have sandbox accounts with AthenaHealth, eClinicalWorks and EPIC. I’ve had some success with Athenahealth using BasicAuthentication with a clientID/Secret to retrieve a token, and then the token can be used to make subsequent requests with proper authorization for the various scopes.

The Python function for that is like below where TOKEN_URL=’/oauth2/v1/token’

def get_access_token():
    response = requests.post(
        TOKEN_URL,
        auth=HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET),
        headers={'Content-Type': 'application/x-www-form-urlencoded'},
        data={
        'grant_type': 'client_credentials',
        'scope': '....'
        }
    )
    response.raise_for_status()
    return response.json()['access_token']

There is also a probably more commonly used OAuth method which is a bit more difficult to implement. My application is a backend app and not even necessarily patient or provider facing, so I would prefer using the above method, but I have thus far been unable to get it to work in the ECW sandbox.

I did try something like this, but I get a 401 error usually:

def get_access_token():
    response = requests.post(
        AUTH_URL,
        headers={'Content-Type': 'application/x-www-form-urlencoded'},
        data={
            'response_type':'code',
            'client_id': '...',
            'redirect_uri':'...',
            'launch':'...',
            'scope': 'patient/Patient.read',
            'state':'12',
            'aud':'https://fhir4.healow.com/fhir/r4/xxxxxx',
            'code_challenge':'...',
            'code_challenge_method':'S256'
        }
    )
    response.raise_for_status()
    return response.json()['access_token']

Their documentation is not bad, and here are some of the highlights:

ECW API documentation

They do state:

Symmetric (Client Secret) Authentication

“Symmetric Authentication authenticates a client using a secret that has been pre-shared between the client and the vendor authorization server. The client authenticates its requests by supplying an authorization header with HTTP basic authentication, where the username is the app’s client_id and the password is the app’s client_secret”

but the python code and variants do not seem to work.

They give an example of how to request an authorization code:

https://{ehr_authorize_url}?response_type=code&client_id=sXuHfoq0ykKSA1HlwI&redirect_uri=https://inferno.healthit.gov/suites/custom/smart/redirect&scope=openid+fhirUser+offline_access+user/Encounter.read+user/Patient.read&state=270579bc-853c-4ed8-a7f4-c8957519b222&aud=https://{fhir_base_url}&code_challenge=NBSSe6w_ABTFmOl0dBC_1dmuYtRJpARHcJAVithSOsA&code_challenge_method=S256

But that also doesn’t work yet. That is somewhat documented here:
SMART App Launch Framework Another problem is that ECW and ‘healow’ appear to have 2 sites to service their customers. e.g. https://fhir.eclinicalworks.com/ecwopendev/documentation#

and FHIR also has detailed documentation: FHIR documentation

Any pointers or suggestion appreciated. The Athena Sandbox works fine after the authentication issue is solved.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật