JWTs Authentication with Go, echo, and GraphQL

A simple tutorial of JWT authentication using Go, echo, and GraphQL

Example Repo

Pre-requisites

Dependencies

go get github.com/dgrijalva/jwt-go

Generate RSA key

$ ssh-keygen -t rsa -m PEM
Generating public/private rsa key pair.
Enter file in which to save the key:
${Your project root path}/id.rsa
ssh-keygen -f id_rsa.pub -e -m pkcs8 > id_rsa.pub.pkcs8

Sign-in

curl -X POST -d 'username=you' -d 'password=passed' localhost:3000/signIn
{
"token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9....
}

Restricting GraphQL

Users data in GraphiQL
Invalid Access
Edit HTTP Headers
Add Header name and value
Successful

Conclusion

Web Developer, TypeScript, React, React Native, Vue.js, Go, Swift, and Ruby on Rails https://manatoworks.me/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store