Next.js Discord

Discord Forum

Better Auth - Microsoft Entra

Unanswered
Harlequin posted this in #help-forum
Open in Discord
HarlequinOP
Hey, I switched to Better Auth to see if my application works faster than next-auth. I configured it, setup config for Microsoft Entra (External Id) as provider, get rid of authjs middleware etc. Seems to be working fine, it's moving me to microsoft login page but I have an problem with using access_token. My Next.js consumes external .NET api and I need to send access_token to it. Problem is that my access_token (which get by using getAccessToken method) is not in proper shape and throws that signature is invalid, I can see that for example issuer is set wrong but config needs to be fine because I can login and get session. I'm using stateless approach without database. I tried to use customSession plugin and there extend session object with manual fetch to /oauth/2.0/token to get actual (and proper) access_token but not sure if it's correct approach. Other thing is that approach required to add getUserInfo to provider config object, get refresh_token from token parameter and pass it to user to use it in customSession 😄 I don't think this is correct approach. I hope that you also faced it and have solution as I spent like 3 days on it.

Greetings

1 Reply

HarlequinOP
bump