GithubHelp home page GithubHelp logo

Comments (5)

vlad-ignatov avatar vlad-ignatov commented on August 19, 2024

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.

martijnkorteweg avatar martijnkorteweg commented on August 19, 2024

Hi @vlad-ignatov

thanks for replying so quickly, here are some more details on how we have it setup

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.

vlad-ignatov avatar vlad-ignatov commented on August 19, 2024

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:

  1. 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"
  2. 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());
  1. 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.

martijnkorteweg avatar martijnkorteweg commented on August 19, 2024

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.

martijnkorteweg avatar martijnkorteweg commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.