...
The fhir-client.js JavaScript library from SMART contains methods to help you handle the SMART on FHIR Authorization workflow with in your app. Include fhir-client.js in a file which will be loaded when your app is launched. In this snippet, we are showing an example of initiating SMART on FHIR Authorization authorization within html HTML code. To request authorization, call the FHIR.oauth2.authorize method. :
Code Block | ||||
---|---|---|---|---|
| ||||
<html> <head> <script src="fhir-client.js"></script> </head> <body> <script type="text/javascript"> FHIR.oauth2.authorize({ client_id: "my_client_id", redirect_uri: "https://mydomain.com/app/index.html", scope: "patient/*.read" }); </script> ... </body> </html> |
...
Include fhir-client.js and jquery in a file which will be redirected to after successful authorization. This snippet is in an html HTML file. Call the FHIR.oauth2.ready method to complete the authorization process and retrieve an access token for interacting with the FHIR server. The resulting SMART FHIR Client (named fhirClient in this example) contains the access token and uses it during interactions with the FHIR server.
...