Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AmazonAPIMap = map[string]string{
"endpoint": "https://api.amazon.com",
"userEndpoint": "/user/profile",
}
AmazonAPIMap is the map for API endpoints
var AmazonDefaultScopes = []string{"profile"}
AmazonDefaultScopes contains the default scopes
var AmazonUserFn = func(client *http.Client, u *structs.User) {}
AmazonUserFn is a callback to parse additional fields for User
var AmazonUserMap = map[string]string{
"user_id": "ID",
"name": "FullName",
"email": "Email",
}
AmazonUserMap is the map to create the User struct
var AsanaAPIMap = map[string]string{
"endpoint": "https://app.asana.com/api/1.0",
"userEndpoint": "/users/me?opt_fields=id,name,email,photo",
}
AsanaAPIMap is the map for API endpoints
var AsanaDefaultScopes = []string{}
AsanaDefaultScopes contains the default scopes
var AsanaEndpoint = oauth2.Endpoint{
AuthURL: "https://app.asana.com/-/oauth_authorize",
TokenURL: "https://app.asana.com/-/oauth_token",
}
DailyMotionEndpoint is the oAuth endpoint
var AsanaUserFn = func(client *http.Client, u *structs.User) { userData := u.Raw["data"].(map[string]interface{}) u.ID = fmt.Sprintf("%.0f", userData["id"].(float64)) u.Email = userData["email"].(string) u.FullName = userData["name"].(string) if userData["photo"] != nil { u.Avatar = userData["photo"].(map[string]interface{})["image_1024x1024"].(string) } }
AsanaUserFn is a callback to parse additional fields for User
var AsanaUserMap = map[string]string{}
AsanaUserMap is the map to create the User struct
var BitbucketAPIMap = map[string]string{
"endpoint": "https://api.bitbucket.org",
"userEndpoint": "/2.0/user",
"emailEndpoint": "/2.0/user/emails",
}
BitbucketAPIMap is the map for API endpoints
var BitbucketDefaultScopes = []string{"account", "email"}
BitbucketDefaultScopes contains the default scopes
var BitbucketUserFn = func(client *http.Client, u *structs.User) { u.Avatar = u.Raw["links"].(map[string]interface{})["avatar"].(map[string]interface{})["href"].(string) req, err := client.Get(BitbucketAPIMap["endpoint"] + BitbucketAPIMap["emailEndpoint"]) if err != nil { return } defer req.Body.Close() res, _ := ioutil.ReadAll(req.Body) data, err := jsonDecode(res) if err != nil { return } u.Email = data["values"].([]interface{})[0].(map[string]interface{})["email"].(string) }
BitbucketUserFn is a callback to parse additional fields for User
var BitbucketUserMap = map[string]string{
"account_id": "ID",
"username": "Username",
"display_name": "FullName",
}
BitbucketUserMap is the map to create the User struct
var FacebookAPIMap = map[string]string{
"endpoint": "https://graph.facebook.com",
"userEndpoint": "/me?fields=id,name,first_name,last_name,email",
}
FacebookAPIMap is the map for API endpoints
var FacebookDefaultScopes = []string{"email"}
FacebookDefaultScopes contains the default scopes
var FacebookUserFn = func(client *http.Client, u *structs.User) { u.Avatar = FacebookAPIMap["endpoint"] + "/v2.8/" + u.ID + "/picture?width=800" }
FacebookUserFn is a callback to parse additional fields for User
var FacebookUserMap = map[string]string{
"id": "ID",
"email": "Email",
"name": "FullName",
"first_name": "FirstName",
"last_name": "LastName",
}
FacebookUserMap is the map to create the User struct
var FoursquareAPIMap = map[string]string{
"endpoint": "https://api.foursquare.com",
"userEndpoint": "/v2/users/self?oauth_token=%ACCESS_TOKEN&v=20171220",
}
FoursquareAPIMap is the map for API endpoints
var FoursquareDefaultScopes = []string{}
FoursquareDefaultScopes contains the default scopes
var FoursquareUserFn = func(client *http.Client, u *structs.User) { user := u.Raw["response"].(map[string]interface{})["user"].(map[string]interface{}) u.ID = user["id"].(string) u.FirstName = user["firstName"].(string) u.LastName = user["lastName"].(string) u.FullName = u.FirstName + " " + u.LastName if email, ok := user["contact"].(map[string]interface{})["email"]; ok { u.Email = email.(string) } if avatarPrefix, ok := user["photo"].(map[string]interface{})["prefix"]; ok { if avatarSuffix, ok2 := user["photo"].(map[string]interface{})["suffix"]; ok2 { u.Avatar = avatarPrefix.(string) + "original" + avatarSuffix.(string) } } }
FoursquareUserFn is a callback to parse additional fields for User
var FoursquareUserMap = map[string]string{}
FoursquareUserMap is the map to create the User struct
var GithubAPIMap = map[string]string{
"endpoint": "https://api.github.com",
"userEndpoint": "/user",
"emailEndpoint": "/user/emails",
}
GithubAPIMap is the map for API endpoints
var GithubDefaultScopes = []string{"user:email"}
GithubDefaultScopes contains the default scopes
var GithubUserFn = func(client *http.Client, u *structs.User) { // Used to parse the email from response type additionalEmail struct { Email string `json:"email"` } var email []additionalEmail if u.Email == "<nil>" { req, err := client.Get(GithubAPIMap["endpoint"] + GithubAPIMap["emailEndpoint"]) if err != nil { return } defer req.Body.Close() err = json.NewDecoder(req.Body).Decode(&email) if err != nil { return } u.Email = email[0].Email } }
GithubUserFn is a callback to parse additional fields for User
var GithubUserMap = map[string]string{
"id": "ID",
"email": "Email",
"login": "Username",
"avatar_url": "Avatar",
"name": "FullName",
}
GithubUserMap is the map to create the User struct
var GoogleAPIMap = map[string]string{
"endpoint": "https://www.googleapis.com",
"userEndpoint": "/oauth2/v2/userinfo",
}
GoogleAPIMap is the map for API endpoints
var GoogleDefaultScopes = []string{"profile", "email"}
GoogleDefaultScopes contains the default scopes
var GoogleUserFn = func(client *http.Client, u *structs.User) {}
GoogleUserFn is a callback to parse additional fields for User
var GoogleUserMap = map[string]string{
"id": "ID",
"email": "Email",
"name": "FullName",
"given_name": "FirstName",
"family_name": "LastName",
"picture": "Avatar",
}
GoogleUserMap is the map to create the User struct
var LinkedInAPIMap = map[string]string{
"endpoint": "https://api.linkedin.com",
"userEndpoint": "/v1/people/~:(id,first-name,last-name,formatted-name,email-address,picture-url,maiden-name,headline,location,industry,current-share,num-connections,summary,specialties,positions,public-profile-url)?format=json",
}
LinkedInAPIMap is the map for API endpoints
var LinkedInDefaultScopes = []string{}
LinkedInDefaultScopes contains the default scopes
var LinkedInUserFn = func(client *http.Client, u *structs.User) {}
LinkedInUserFn is a callback to parse additional fields for User
var LinkedInUserMap = map[string]string{
"id": "ID",
"vanityName": "Username",
"firstName": "FirstName",
"lastName": "LastName",
"formattedName": "FullName",
"emailAddress": "Email",
"pictureUrl": "Avatar",
}
LinkedInUserMap is the map to create the User struct
var MicrosoftAPIMap = map[string]string{
"endpoint": "https://graph.microsoft.com",
"userEndpoint": "/v1.0/me",
}
MicrosoftAPIMap is the map for API endpoints
var MicrosoftDefaultScopes = []string{"User.Read"}
MicrosoftDefaultScopes contains the default scopes
var MicrosoftUserFn = func(client *http.Client, u *structs.User) {}
MicrosoftUserFn is a callback to parse additional fields for User
var MicrosoftUserMap = map[string]string{
"id": "ID",
"givenName": "Username",
"displayName": "FullName",
"userPrincipalName": "Email",
}
MicrosoftUserMap is the map to create the User struct
var SlackAPIMap = map[string]string{
"endpoint": "https://slack.com/api",
"userEndpoint": "/users.profile.get",
"authEndpoint": "/auth.test",
}
SlackAPIMap is the map for API endpoints
var SlackDefaultScopes = []string{"users.profile:read"}
SlackDefaultScopes contains the default scopes
var SlackUserFn = func(client *http.Client, u *structs.User) { req, err := client.Get(SlackAPIMap["endpoint"] + SlackAPIMap["authEndpoint"]) if err != nil { return } defer req.Body.Close() res, _ := ioutil.ReadAll(req.Body) data, err := jsonDecode(res) if err != nil { return } u.ID = data["user_id"].(string) userInfo := u.Raw["profile"].(map[string]interface{}) u.Username = userInfo["display_name"].(string) u.FullName = userInfo["real_name"].(string) u.FirstName = userInfo["first_name"].(string) u.LastName = userInfo["last_name"].(string) u.Email = userInfo["email"].(string) u.Avatar = userInfo["image_original"].(string) }
SlackUserFn is a callback to parse additional fields for User
var SlackUserMap = map[string]string{
"real_name": "FullName",
"first_name": "FirstName",
"last_name": "LastName",
"email": "Email",
"image_original": "Avatar",
}
SlackUserMap is the map to create the User struct
Functions ¶
Types ¶
This section is empty.