This document captures the launch sequence from the SMART on FHIR sandbox for en EHR launch.
After retriving the /metadata
contents, the client initiates the authorization:
GET https://launch.smarthealthit.org/v/r3/auth/authorize?client_id=whatever&response_type=code&scope=patient%2F*.*%20user%2F*.*%20launch%20openid%20profile%20offline_access&redirect_uri=https%3A%2F%2Flaunch.smarthealthit.org%2Fsample-app%2F&state=4e279d50-8a8f-be82-2803-c7136fdb4ff3&aud=&launch=eyJhIjoiMSIsImYiOiIxIn0&provider=smart-Practitioner-71482713&login_type=provider&aud_validated=1&login_success=1&patient=b2536dd3-bccd-4d22-8355-ab20acdf240b&select_first=true&encounter=e3ec2d15-4c27-4607-a45c-2f84962b0700
Note that patient
, encounter
, provider
are passed as URL parameters to /authorize
The code is then returned:
GET https://launch.smarthealthit.org/sample-app/?code=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb250ZXh0Ijp7Im5lZWRfcGF0aWVudF9iYW5uZXIiOmZhbHNlLCJzbWFydF9zdHlsZV91cmwiOiJodHRwczovL2xhdW5jaC5zbWFydGhlYWx0aGl0Lm9yZy9zbWFydC1zdHlsZS5qc29uIiwicGF0aWVudCI6ImIyNTM2ZGQzLWJjY2QtNGQyMi04MzU1LWFiMjBhY2RmMjQwYiIsImVuY291bnRlciI6ImUzZWMyZDE1LTRjMjctNDYwNy1hNDVjLTJmODQ5NjJiMDcwMCJ9LCJjbGllbnRfaWQiOiJ3aGF0ZXZlciIsInNjb3BlIjoicGF0aWVudC8qLiogdXNlci8qLiogbGF1bmNoIG9wZW5pZCBwcm9maWxlIG9mZmxpbmVfYWNjZXNzIiwidXNlciI6IlByYWN0aXRpb25lci9zbWFydC1QcmFjdGl0aW9uZXItNzE0ODI3MTMiLCJpYXQiOjE1NDI4OTI3MTMsImV4cCI6MTU0Mjg5MzAxM30.gmnZofjX7rxIrguroUJw4UgJr8xXVdfDXvKCbXfM2q8&state=4e279d50-8a8f-be82-2803-c7136fdb4ff3
Note that the code
itself is a JWT. The contents of this token is:
{
"context": {
"need_patient_banner": false,
"smart_style_url": "https://launch.smarthealthit.org/smart-style.json",
"patient": "b2536dd3-bccd-4d22-8355-ab20acdf240b",
"encounter": "e3ec2d15-4c27-4607-a45c-2f84962b0700"
},
"client_id": "whatever",
"scope": "patient/*.* user/*.* launch openid profile offline_access",
"user": "Practitioner/smart-Practitioner-71482713",
"iat": 1542892713,
"exp": 1542893013
}
So the code
is now being used to transport the patient
, encounter
, etc.
Finally a token is obtained with:
POST https://launch.smarthealthit.org/v/r3/auth/token
The request body of the message is:
client_id: whatever
code: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb250ZXh0Ijp7Im5lZWRfcGF0aWVudF9iYW5uZXIiOmZhbHNlLCJzbWFydF9zdHlsZV91cmwiOiJodHRwczovL2xhdW5jaC5zbWFydGhlYWx0aGl0Lm9yZy9zbWFydC1zdHlsZS5qc29uIiwicGF0aWVudCI6ImIyNTM2ZGQzLWJjY2QtNGQyMi04MzU1LWFiMjBhY2RmMjQwYiIsImVuY291bnRlciI6ImUzZWMyZDE1LTRjMjctNDYwNy1hNDVjLTJmODQ5NjJiMDcwMCJ9LCJjbGllbnRfaWQiOiJ3aGF0ZXZlciIsInNjb3BlIjoicGF0aWVudC8qLiogdXNlci8qLiogbGF1bmNoIG9wZW5pZCBwcm9maWxlIG9mZmxpbmVfYWNjZXNzIiwidXNlciI6IlByYWN0aXRpb25lci9zbWFydC1QcmFjdGl0aW9uZXItNzE0ODI3MTMiLCJpYXQiOjE1NDI4OTI3MTMsImV4cCI6MTU0Mjg5MzAxM30.gmnZofjX7rxIrguroUJw4UgJr8xXVdfDXvKCbXfM2q8
grant_type: authorization_code
redirect_uri: https%3A%2F%2Flaunch.smarthealthit.org%2Fsample-app%2F
And finally the token response:
{
"need_patient_banner": false,
"smart_style_url": "https://launch.smarthealthit.org/smart-style.json",
"patient": "b2536dd3-bccd-4d22-8355-ab20acdf240b",
"encounter": "e3ec2d15-4c27-4607-a45c-2f84962b0700",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb250ZXh0Ijp7Im5lZWRfcGF0aWVudF9iYW5uZXIiOmZhbHNlLCJzbWFydF9zdHlsZV91cmwiOiJodHRwczovL2xhdW5jaC5zbWFydGhlYWx0aGl0Lm9yZy9zbWFydC1zdHlsZS5qc29uIiwicGF0aWVudCI6ImIyNTM2ZGQzLWJjY2QtNGQyMi04MzU1LWFiMjBhY2RmMjQwYiIsImVuY291bnRlciI6ImUzZWMyZDE1LTRjMjctNDYwNy1hNDVjLTJmODQ5NjJiMDcwMCJ9LCJjbGllbnRfaWQiOiJ3aGF0ZXZlciIsInNjb3BlIjoicGF0aWVudC8qLiogdXNlci8qLiogbGF1bmNoIG9wZW5pZCBwcm9maWxlIG9mZmxpbmVfYWNjZXNzIiwidXNlciI6IlByYWN0aXRpb25lci9zbWFydC1QcmFjdGl0aW9uZXItNzE0ODI3MTMiLCJpYXQiOjE1NDI4OTI3MTMsImV4cCI6MTU3NDQyODcxNn0.57HMcZf5vHwCceZM2UZRiUhWBxplN_Ytr3frX-q-4Q0",
"token_type": "bearer",
"scope": "patient/*.* user/*.* launch openid profile offline_access",
"client_id": "whatever",
"expires_in": 3600,
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJwcm9maWxlIjoiUHJhY3RpdGlvbmVyL3NtYXJ0LVByYWN0aXRpb25lci03MTQ4MjcxMyIsImF1ZCI6IndoYXRldmVyIiwic3ViIjoiZGIyM2QwZGUyNTY3OGU2NzA5OWJjNDM0MzIzZGMwZDk2NTEzYjU1MjJkNGI3NDFjYmEzOWY3YzkyZDBjNDZhZSIsImlzcyI6Imh0dHBzOi8vbGF1bmNoLnNtYXJ0aGVhbHRoaXQub3JnIiwiaWF0IjoxNTQyODkyNzE2LCJleHAiOjE1NDI4OTYzMTZ9.4Ehr5amtWKoHf0HCooo99oMb9qBMl99aT129lp49tZF4RTWD8WhJaNZClYNJCdV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