Skip to content

Commit

Permalink
graph api for microsoft online
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Pristas authored and markbates committed Jan 23, 2018
1 parent e323d70 commit a13db52
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions providers/microsoftonline/microsoftonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
const (
authURL string = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
tokenURL string = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
endpointProfile string = "https://outlook.office.com/api/v2.0/me"
endpointProfile string = "https://graph.windows.net/v1.0/me"
)

// New creates a new microsoftonline provider, and sets up important connection details.
Expand Down Expand Up @@ -146,32 +146,32 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {
c.Scopes = append(c.Scopes,
"openid",
"offline_access",
"https://outlook.office.com/Mail.ReadWrite",
"https://outlook.office.com/Calendars.ReadWrite",
"https://outlook.office.com/Contacts.ReadWrite")
"user.read")
}

return c
}

func userFromReader(r io.Reader, user *goth.User) error {
u := struct {
ID string `json:"Id"`
Name string `json:"DisplayName"`
Email string `json:"EmailAddress"`
Alias string `json:"Alias"`
MailboxGUID string `json:"MailboxGuid"`
ID string `json:"id"`
Name string `json:"displayName"`
FirstName string `json:"givenName"`
LastName string `json:"surname"`
UserPrincipalName string `json:"userPrincipalName"`
}{}

err := json.NewDecoder(r).Decode(&u)
if err != nil {
return err
}

user.UserID = u.ID
user.Email = u.Email
user.Email = u.UserPrincipalName
user.Name = u.Name
user.NickName = u.Alias
user.FirstName = u.FirstName
user.LastName = u.LastName
user.NickName = u.Name
user.UserID = u.ID

return nil
}
Expand Down

0 comments on commit a13db52

Please sign in to comment.