forked from danilopolani/gocialite
/
google.go
36 lines (28 loc) · 949 Bytes
/
google.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package drivers
import (
"net/http"
"github.com/danilopolani/gocialite/structs"
"golang.org/x/oauth2/google"
)
const googleDriverName = "google"
func init() {
registerDriver(googleDriverName, GoogleDefaultScopes, GoogleUserFn, google.Endpoint, GoogleAPIMap, GoogleUserMap)
}
// GoogleUserMap is the map to create the User struct
var GoogleUserMap = map[string]string{
"id": "ID",
"email": "Email",
"name": "FullName",
"given_name": "FirstName",
"family_name": "LastName",
"picture": "Avatar",
}
// GoogleAPIMap is the map for API endpoints
var GoogleAPIMap = map[string]string{
"endpoint": "https://www.googleapis.com",
"userEndpoint": "/oauth2/v2/userinfo",
}
// GoogleUserFn is a callback to parse additional fields for User
var GoogleUserFn = func(client *http.Client, u *structs.User) {}
// GoogleDefaultScopes contains the default scopes
var GoogleDefaultScopes = []string{"profile", "email"}