# README
PTGU OAuth Google
Import
import (
PTGUoauth "github.com/parinyapt/golang_utils/oauth/google/v1"
)
Example
Config OAuth
googleOAuth := PTGUoauth.NewGoogleOAuth(&oauth2.Config{
RedirectURL: "URL_TO_REDIRECT_AFTER_LOGIN",
ClientID: "CLIENT_ID",
ClientSecret: "CLIENT_SECRET",
Scopes: []string{
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
},
Endpoint: google.Endpoint,
})
Generate Login URL
loginURL := googleOAuth.GenerateLoginURL("STATE")
Get Access Token by Code
accessToken, err := googleOAuth.GetAccessToken("CODE")
if err != nil {
panic(err)
}
Get Token Info by Access Token
tokenInfo, validateStatus, err := googleOAuth.GetTokenInfo(accessToken)
if err != nil {
panic(err)
}
fmt.Println(tokenInfo.AUD)
fmt.Println(tokenInfo.UserID)
fmt.Println(tokenInfo.Email)
fmt.Println(validateStatus.Aud)
fmt.Println(validateStatus.Exp)
Get User Info by Access Token
userInfo, err := googleOAuth.GetUserInfo(accessToken)
if err != nil {
panic(err)
}
fmt.Println(userInfo.UserID)
fmt.Println(userInfo.Email)
fmt.Println(userInfo.Name)
fmt.Println(userInfo.Picture)
# Functions
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author