DEV Community

Oauth2 with Google in Go

Douglas Makey Mendez Molero on July 10, 2018

Authentication is the most common part in any application. You can implement your own authentication system or use one of the many alternatives tha...
Collapse
 
plutov profile image
Alex Pliutau

Nice article, and surprisingly similar to my video - youtu.be/OdyXIi6DGYw

Collapse
 
glowned profile image
Glowned • Edited

@alex Pliutau Nice video anyway ;)

Collapse
 
douglasmakey profile image
Douglas Makey Mendez Molero

You can use JWT for protected your endpoints, in the function oauthGoogleCallback when the login is succeeded you can create the user in your DB and generate the token and return to the user.

JWT: github.com/dgrijalva/jwt-go

Collapse
 
egor58461029 profile image
Egor Yudin

So it's okay to get tokens from 3rd party, read user's email from them, add user to database, generate my own tokens, with payload I need, and send them to the client? I thought that it's necessary to send 3rd party's tokens to the client, because they have their own expiration time.