Comments (5)
Hi @martijnkorteweg,
Thank you for checking out the latest version! There might be an issue, but I will need more info to reproduce it.
After the redirect happens the state param on the url seems to disappear in our application. It does get set as the redirect url however when login is complete the state param is gone.
That is how it is supposed to work, unless you've set FHIR.oauth2.settings.fullSessionStorageSupport
or FHIR.oauth2.settings.replaceBrowserHistory
to false.
The real problem would be that you don't have SMART_KEY set in your sessionStorage. Can you share more details? How are you launching your app, in what browser and OS, against which FHIR server, etc
P.S. This is to be released soon, but until then it changes frequently. You might have tried an already outdated version. Until it gets to NPM, it might be more convenient to make sure you are always using the latest build by including it as so:
<script src="https://combinatronics.com/smart-on-fhir/client-js/master/build/fhir-client.js"></script>
from client-js.
thanks for replying so quickly, here are some more details on how we have it setup
- we are on the latest chrome
- running the auth script in a component/route in angular 6
- gets redirected to a different component/route
- using the http://launch.smarthealthit.org launcher with localhost app
- importing the library with npm like this: "fhirclient": "git+https://github.com/smart-on-fhir/client-js.git",
if you do want to recreate with angular 6, you will need to import fhirClient in polyfills.ts before zone.js gets imported otherwise they conflict and start yelling :)
as far as not having SMART_KEY set in sessionStorage, i don't see this being set at all in authorize()
. the only key its being set to is here await env.getStorage().set(stateKey, state);
in completeAuth()
it does have the line if there is no key
if (!key) {
key = await Storage.get(SMART_KEY);
}
how ever this sets key
to the value and not the key itself, then the call later on fails because of that.
let state = await Storage.get(key);
from client-js.
Hi @martijnkorteweg ,
I don't do Anglular so I hope you can excuse my confusion. In general though, I would say that you should be careful how you use this library, because it is doing some "global" stuff like redirects and sessionStorage manipulation. Here are some advices that might help with this:
- Include the library via script tag. Don't try to require it as a module. Use the pre-built bundle from "/build/fhir-client.js"
- When using frameworks (especially those with built-in routing functionality), make sure you initialize your app after the
FHIR.oauth2.ready()
promise is resolved. For example:
// This should be fine
FHIR.oauth2.ready().then(client => {
// Create/initialize my app
});
// This might not work properly (pseudo code)
const app = new App();
app.onSomeRoute(() => FHIR.oauth2.ready());
- Perhaps if you set
localStorage.debug = 'FHIRClient:*'
and look at the logs it will tell us something useful?
As for the auth flow, the SMART_KEY is only written once the authorization is complete at https://github.com/smart-on-fhir/client-js/blob/master/src/smart.js#L343
from client-js.
It seems i have found the issue, it def has something todo with angular. the redirect lands on
uri/?state=....#/componentRoute
. the state at that point gets removed by angular since it comes before the #/
Trying to figure out a work around for this. will let you know where i land on this
from client-js.
Hey @vlad-ignatov
So I have tried the two settings you said, this doesn't seem to help my issue. However not using the hash locations in angular does fix our issue. Lets hope none of our customers want to run this on IE9 :)
thank you for you time.
from client-js.
Related Issues (20)
- Client request pre-pends accept header when provided in options HOT 6
- Support for CryptoKey objects as private keys HOT 6
- 502 Gateway Error on codesandbox HOT 2
- Failing in web client projects due to NodeJS usage without polyfills. HOT 13
- Support for browser using multiple SMART clients at once. HOT 3
- Unable to authorize using PKCE HOT 2
- Typo in README
- Unable to get patientId after successful login HOT 1
- (Error handling skipped on init) CompleteAuth not triggered for init HOT 1
- includeResponse not working for FHIR update operations
- "target: popup" (etc) demos don't work in current Chromium HOT 2
- Single SMART_KEY breaks authorization of several users on server-side
- Jest + RTL :: Testing with FHIRClient
- Uncaught (in promise) Error: Failed to fetch the conformance statement from "https://staging-fhir.ecwcloud.com/fhir/r4/FFBJCD/metadata". TypeError: Network request failed HOT 6
- Question: Smart-On-Fhir implementation inside Service Worker
- FHIR type Meta requiring lastUpdated property when spec allows it to be optional
- Node js After 10 min 401 unauthorized response HOT 4
- Window closes itself when it's not actually a popup
- Save token info in DB
- Support of PKCE even when the EHR .well-known configuration is not set? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from client-js.