1

If I am logged in (have a session cookie) and make a GET request to /jwt/token, then I get a JWT token. How do I get the token if I am not logged in?

This article by Preston So states:

As a logged-in user, or when you issue a GET request against /jwt/token with credentials of a user with the appropriate permissions, you will receive a token like that seen below, with which we can issue authenticated requests to Drupal.

So this is what I tried in Postman:

  • GET: example.com/jwt/token
  • Headers: Content-Type: application/json
  • Body: raw: {"name": "myUsername", "pass: "password"}

This resulted in an "access denied" message.

I also tried using form-data and x-www-form-urlencoded for the Body, but those didn't work either.

I know JWT is configured correctly because if I log in first in Postman (get a session cookie) and then try the request, it gives me the token.

So what can I use in Postman to get the token from /jwt/token when I'm not already logged in? (How do I provide my login info to Postman?)

1
  • 1
    basic_auth is mentioned in the route for /jwt/token, maybe try username:[email protected]/jwt/token. The body is usually ignored for GET requests so it makes sense that what you tried didn't work
    – Clive
    Mar 6, 2021 at 19:55

0

Your Answer

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

Browse other questions tagged or ask your own question.