Easy build API using Laravel and GraphQL (JWT Authentication) part 3
JWT Authentication GraphQL
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA
1. Install JWT Package
JWT very useful for API Authentication Stateless and easy to integrate with Laravel using this package
Installation JWT, you can follow this instruction here and for handling error here.
2. Create Controller For Authentication
we use header paramAuthorization: Bearer {yourtokenhere}
every request to GraphQL. First create controller for authentication like below