Login to Headless Wordpress via AUTH0

Hello Community,

i am building headless woocommerce solution that is using Auth0 for authentication, on Vercel/Next.js/React side of app i have added a login button that redirect to my tenant login which when you successfully login redirects back to the App with user info from auth0 and i have established session with auth0.

On the CMS side i have Wordpress/Woocommerce which has Auth0 plugin installed and also app connection between auth0 and wordpress/woocommerce part is established, when you visit sitename/wp-admin and you have session from auth0 you would be instant logged in.

Now what i am currently missing is session with woocommerce in app, i am using graphql requests which require session token and auth token from woocommerce, how do i retrieve that once i am logged in auth0 and have active session there? So the flow would be to go to Vercel app click login button → redirect to tenant @ authcom → redirect back to Vercel app once logged successfully on auth0 → session established with Woocommerce too so i can send further correct requests to WP.

Hi @branislav.meandzija

Thank you for reaching out!
Reading through your post, I’m wondering if the wp_get_session_token(): string function is not the missing piece in the puzzle. Based on this documentation from WordPress, it is used to retrieve the current session token from the logged_in cookie.

Let me know if this helped!
Gerald