I am working on a single page application using NUXT and Drupal 8 as headless CMS. for user authentication token I am using Simple OAuth Drupal 8 module. Everything is working fine. I am getting the access token when I send request to this API https://website.com/oauth/token as you can see below.

enter image description here

What I want now is to authenticate the user using this token. How will I get the user detail every time I refresh the page using this response? Is there any API where we send the access token with the bearer .

Excuse me Please if I am using the wrong terms I am new to Decoupled.

But as you know setting up JWT for authentication. we send two requests. 1 request to get the token and another request to get the user using that token as mention in this tutorial.

I don't know if I made my point clear. I am totally lost here.


1 Answer 1


I'm not familiar with the Nuxtjs framework discussed in the tutorial you linked to, but basically once you have the access_token the user should be authenticated in Drupal. It should be enough that you on each request set an Authorization header that contains that access token, as described in the tutorial:

this.$axios.setHeader('Authorization', 'Bearer ' + resp.data.access_token)

Drupal will then read the Authorization header value and authenticate/authorize the user based on the Drupal role that the user has assigned to itself. So provided you have the REST endpoints for user information active you should be able to make a GET request to /user/{user} and get the logged in user information.

You can try this out using curl or Postman by manually adding the header to the request:

Authorization: Bearer HereGoesTheValueOfTheAccessToken

A curl example:

curl --request GET \
  --url https://mydrupaldomain.com/user/123 \
  --header 'authorization: Bearer HereGoesTheValueOfTheAccessToken'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.