Assistance in trying to connect Auth0 to Medplum
# support
z
I've been looking through this repository: https://github.com/medplum/medplum/tree/main/examples/medplum-client-external-idp-demo. I have created an Auth0 account, and project. I believe I have the correct configurations. I double checked to make sure. I have attached screen shots of where I obtained different pieces of information. The first screenshot has the domain, as well as the external client id and secret (although the secret doesn't get used). The second screen shot has the medplum project id. The third screen shot is where I go my medplum client id (I created a ClientApplication and that's where the id appeared). The next screenshot from auth0 has all the URLs (authorize, userinfo, etc) that I added to the cloned repo as well as to the client app. I start the app with
Copy code
npm run dev
to get the app running. It shows me the initial sign in page (next screen shot). But when I press sign in I get the final screen shot. I'll also add it here in a tiny code block:
Copy code
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "text": "User not found"
      }
    }
  ],
  "extension": [
    {
      "url": "https://medplum.com/fhir/StructureDefinition/tracing",
      "extension": [
        {
          "url": "requestId",
          "valueId": "283d0627-7f9e-40a3-88c0-531f8519610f"
        },
        {
          "url": "traceId",
          "valueId": "1-67ab94a4-68033d6b2d7e128d75c6f314"
        }
      ]
    }
  ]
}
I don't understand what's going wrong. The only thing that seems to change the behaviour is the medplum api link that I was instructed to use as the redirect uri inside the auth0 configurations online.
Copy code
https://api.medplum.com/auth/external
I think that was the link. I'd appreciate any help with this. If you need more information, I'm happy to provide it
Update, so apparently it let me login, but as soon as it finishes, it just goes back to the sign in page. checking the console logs, I noticed that the code = null
^^ there's this segment of the code for reference that does this:
Copy code
// The code check
  // If the current URL includes a "code" query string param, then we can exchange it for a token
  const code = new URLSearchParams(window.location.search).get('code');

useEffect(() => {
    console.log('Got code', code);
    if (code) {
      // Process the code
      // On success, remove the query string parameters
      medplum
        .processCode(code)
        .then(() => navigate('/'))
        .catch(console.error);
    }
  }, [medplum, navigate, code]);
r
Hi @zainaltaf , usually this error indicates that your project doesnt' have user registered with a matching email
Have you double checked that you have a medplum user registered, with the same email as the user logging into Auth0
z
hi @rahul1 yes I have the same email registered as a user in medplum. I hadn't known that the network tab existing in the inspecting tool but I just found it. When I do the login, the network tab shows me this (screen shot). I believe it's a token of some sorts. I also got a code in the networks tab but it's not being used (also a screen shot attached)? The only things I modified in the repository were the strings that we need to put from the external auth provider. Rahul if you know what could possibly be wrong please let me know. Thanks!
UPDATE: I realize the screen shots could have sensitive information so I took them out
but in the networks tab of the inspect tool I can see a token and code
Hi again @rahul1 ! Just wanted to follow up on this. If the external auth doesn’t work, does medplum documentation maybe have built in auth that I can use instead? If so could you point me in the right direction? Thanks!
r
Hi @zainaltaf ! Medplum does have build-in auth - here is the guide for the SDK https://www.medplum.com/docs/auth/methods#medplum-as-identity-provider
z
Awesome thanks!
186 Views