codejenn
08/14/2023, 10:16 PMstartLogin providing email/pwd as we get an error that it is missing property crypto. I have looked at the example app and do note that iOS and Android are not supported in that example and only web based which is not helpful for a mobile app.
I did find a conversation that asked about missing grant_type in the oauth2/token request but no response to that.
I have done a medplum.post to auth/login which has given me a code
Attempting to do medplum.post to oauth2/token providing a content type and params and although I have provided grant_type it is failing. I found a link to https://docs.medplum.com/api/oauth/token which is a broken link as are the other links on this repo https://github.com/medplum/medplum-oauth-demo
This may be a moot point as we plan to implement our current indetity provider BUT for our POC we are trying to avoid that integration.
Hoping this isn't a heavy lift to test the patient facing app on mobile.rahul1
08/14/2023, 10:40 PMrahul1
08/14/2023, 10:48 PMrahul1
08/14/2023, 10:49 PMcrypto, I'd be happy to look in more detailcodejenn
08/15/2023, 12:00 AMinvalid request missing grant_type
The steps I have taken via code:
medplum
.post('auth/login', { email, password })
.then(handleAuthResponse);
//attempt to exchange code for accessToken- results in missing grant_type
medplum
.post(
'oauth2/token',
{
code: response.code,
grant_type: 'authorization_code',
client_id: 'MY_CLIENT_ID',
},
'application/x-www-form-urlencoded',
{ headers: { Authorization: `Basic ${authHeader}` } },
)
.then(setProfile);
//using fetch example for token get same results as medplum.post
const body = {
grant_type: 'authorization_code',
client_id: 'MY_CLIENT_ID',
code: response.code,
};
const authHeader = base64.encode(`${clientId}:${clientSecret}`);
fetch('https://api.medplum.com/oauth2/token', {
method: 'POST',
body: JSON.stringify(body),
headers: {
// "Content-Type": "application/json",
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: 'Basic ' + authHeader,
},
})
.then((res) => res.json())
// .then(showOutput)
.then((res) => console.log(res.access_token));
Attaching a screen grab of the network traffic to show the request body/response where you can see I do include the grant_type as shown in the code above.rahul1
08/15/2023, 12:15 AMrahul1
08/15/2023, 12:15 AMrahul1
08/15/2023, 12:17 AM${clientId}:${clientSecret});codejenn
08/15/2023, 12:37 AMcodejenn
08/15/2023, 12:37 AMrahul1
08/15/2023, 12:38 AMrahul1
08/15/2023, 12:41 AMrahul1
08/15/2023, 12:41 AMcodejenn
08/15/2023, 12:47 AMrahul1
08/15/2023, 12:59 AM/authorize doesn't match the code sent during /token
1. When you call /authorize, were you getting a successful redirect to the medplum authentication screen?
2. After the user logged in, were you getting a successfull redirect back to your redirect_uri, with a code?
3. You sent that code to the /token, but got an "invalid client" errorrahul1
08/15/2023, 1:00 AM/authorize? I can try to run some diagnostics on my endcodejenn
08/15/2023, 1:17 AMrahul1
08/15/2023, 1:21 AMstart** commands will forward along the all the clientId inforahul1
08/15/2023, 1:21 AMsignInWithRedirect method?codejenn
08/15/2023, 1:22 AMrahul1
08/15/2023, 1:22 AMcodejenn
08/15/2023, 1:22 AMcodejenn
08/15/2023, 4:34 AMrahul1
08/22/2023, 11:17 PMboarahul1
08/22/2023, 11:17 PMcodejenn
08/23/2023, 6:21 PMrahul1
08/23/2023, 7:46 PMcodejenn
09/01/2023, 7:19 PM