Documentation ¶
Overview ¶
Package google provides you access to Google's OAuth2 infrastructure. The implementation is based on this blog post: http://skarlso.github.io/2016/06/12/google-signin-with-go/
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth() gin.HandlerFunc
Auth is the google authorization middleware. You can use them to protect a routergroup. Example:
private.Use(google.Auth()) private.GET("/", UserInfoHandler) private.GET("/api", func(ctx *gin.Context) { ctx.JSON(200, gin.H{"message": "Hello from private for groups"}) }) func UserInfoHandler(ctx *gin.Context) { ctx.JSON(http.StatusOK, gin.H{"Hello": "from private", "user": ctx.MustGet("user").(google.User)}) }
func GetLoginURL ¶
func LoginHandler ¶
func Session ¶
func Session(name string) gin.HandlerFunc
Types ¶
type Credentials ¶
Credentials stores google client-ids.
type User ¶
type User struct { Sub string `json:"sub"` Name string `json:"name"` GivenName string `json:"given_name"` FamilyName string `json:"family_name"` Profile string `json:"profile"` Picture string `json:"picture"` Email string `json:"email"` EmailVerified bool `json:"email_verified"` Gender string `json:"gender"` Hd string `json:"hd"` }
User is a retrieved and authenticated user.
Click to show internal directories.
Click to hide internal directories.