This function can be used when you want to handle everything in one page
(no launch endpoint needed). You can think of it as if it does:
authorize(options).then(ready)
Be careful with init()! There are some details you need to be aware of:
It will only work if your launch_uri is the same as your redirect_uri.
While this should be valid, we can’t promise that every EHR will allow you
to register client with such settings.
Internally, init() will be called twice. First it will redirect to the
EHR, then the EHR will redirect back to the page where init() will be
called again to complete the authorization. This is generally fine,
because the returned promise will only be resolved once, after the second
execution, but please also consider the following:
You should wrap all your app’s code in a function that is only executed
after init() resolves!
Since the page will be loaded twice, you must be careful if your code
has global side effects that can persist between page reloads
(for example writing to localStorage).
For standalone launch, only use init in combination with offline_access
scope. Once the access_token expires, if you don’t have a refresh_token
there is no way to re-authorize properly. We detect that and delete the
expired access token, but it still means that the user will have to
refresh the page twice to re-authorize.
This function can be used when you want to handle everything in one page (no launch endpoint needed). You can think of it as if it does:
Be careful with init()! There are some details you need to be aware of:
init()will be called twice. First it will redirect to the EHR, then the EHR will redirect back to the page where init() will be called again to complete the authorization. This is generally fine, because the returned promise will only be resolved once, after the second execution, but please also consider the following:init()resolves!