Welcome to the Kinde community.

A
A
A
M
T

Getting an access token for a given user using the management api

Using the Management API, is there a way to get an access token for a given user (by id or email)?

A
M
B
7 comments

you can use the refreshTokens helper via the SDK to get the access tokens. I can get a code snippet for you https://docs.kinde.com/developer-tools/sdks/backend/nextjs-sdk/#refreshing-kinde-data

Don’t I need to be logged in to call refreshTokens?
I’d like to get an access token for a given user while being logged out. All I have is access to the management API.

My use case, in case it helps:
I have a seeding script for e2e tests where I’d like to emulate a user calling an external API to perform a certain action.
I need an access token of the specific user so that the external API knows the user who is trying to perform the action.

Hey, I think something similar would be great as well as it allows us to test guarded api's.

I do think what we are probably waiting for is - https://updates.kinde.com/board/user-impersonation - but if there is something in the meantime that works, then that would be great

I know what you will find here isnt exactly what you originally asked, but it does describe how you can do E2E testing with Kinde currently. Please ask questions https://kinde.notion.site/End-to-end-testing-with-Kinde-June-2024-d7937db7be784239ac949b740ab830ca?pvs=4 cc

Is it possible to make the call to /oauth2/token using @kinde/management-api-js ?

also, is it expected to get a new refresh token back or will I get back the same refresh token I sent in the request?

Add a reply
Sign up and join the conversation on Slack
Join