How to generate Customer token GraphQL Query Magento 2?

Generate Customer Token GraphQL mutation for any query that requires customer authentication to load data using GraphQL.

generateCustomerToken() mutation is used to create a token.

You just have to pass your email id and password to the mutation to create a customer token.

Generate Customer Token Query,

mutation {
  generateCustomerToken(
   email: "rakesh.jesadiya27@test.com"
   password: "fake12345678"
  ) {
    token
  }
}

In the output, the token field will be the value of your customer authorization bearer value.

Output

{
  "data": {
    "generateCustomerToken": {
      "token": "prq1sal5lw6um24vmuq9tdrzym4pl74c"
    }
  }
}

Still, you are not able to log in with a valid email and password?

Header: Store store_view_code

You have to pass the header with store = store_view_code to retrieve the customer token.

You can use the token value in any query/mutation with an authorization header.
Authorization Bearer prq1sal5lw6um24vmuq9tdrzym4pl74c

This is the simplest way to achieve a customer token in GraphQL.

You can do the same thing Using REST API by How to generate customer access tokens by REST API Magento 2?