Golang oAuth2 Google Example for Web and API System
Construct the OAuth config like this:
var ( googleOauthConfig = &oauth2.Config{ RedirectURL: "http://localhost:9000/GoogleCallback", ClientID: "", ClientSecret: "", Scopes: []string{"https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"}, Endpoint: google.Endpoint, } oauthStateString = "random" )
Construct the DB in Google_User_Table table struct
GoogleUserTable struct {
Id int orm:"column(id);auto"
Name string orm:"column(name);size(225)"
Email string orm:"column(email);size(225)"
Role string orm:"column(role)"
Picture string orm:"column(picture)"
Hd string orm:"column(hd)"
VerifiedEmail int8 orm:"column(verified_email)"
AuthId string orm:"column(auth_id);size(256)"
}