0

I am creating user authentification with Drupal 9 + NuxtJS. Using Simple Oauth module and create post requests to

oauth/token

with data

const data = {
  grant_type: 'password',
  client_id: '',
  client_secret: '!',
  username: username,
  password: password,
}

So, how can I get this client_id, client_secret to past it in JS file ?

1 Answer 1

0

Maybe these following modules will help you, I was once stuck with the same issue for the authentication. My Drupal application was decoupled (Frontend - Vue and Backend - Drupal 9)

I installed the following contributed modules: JWT, and Get JWT on Login.

And just call the login (https://your-drupal-site/user/login?_format=json) endpoint with provided credentials, it will send you back the user's details:

{
    "current_user": {
        "uid": "1",
        "name": "admin"
    },
    "csrf_token": "UlGb7fak5ZS-r1BRistBh4IWLm_Z7F1xMpY3KYTGqcU",
    "logout_token": "7AvbnHgr9iDxIDVertHTI3PMX2-Shd6sjuN8hNHrHv8F",
    "access_token": "eyJ0eXAiOiJKV1QiLDJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE1NDg2NzA3NDUsImV4cCI6MTU0ODY3NDM0NSwiZHJ1cGAsIjp7InVpZCI6IjYifX0.cnG6atSLYrRh6D05LZg9RwrJJdYoJfTBXTUZboPhJH3lYf640FmQTkJwwy9E8kg7ot59qyb5qtgIewM3R1KCDw"
}
1

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.