Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserPhoto ¶
func GetUserPhoto(sessID string, token *GraphToken, w io.Writer) error
GetUserPhoto get user photo with access token
refer: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/profilephoto_get
Types ¶
type GraphError ¶
type GraphError struct { Error string `json:"error,omitempty"` Description string `json:"error_description,omitempty"` Codes []int `json:"error_codes,omitempty"` Timestamp string `json:"timestamp,omitempty"` TraceID string `json:"trace_id,omitempty"` }
GraphError wrap of Graph API error
type GraphToken ¶
type GraphToken struct { AccessToken string `json:"access_token,omitempty"` Type string `json:"token_type,omitempty"` ExpireAt int64 `json:"expires_in,omitempty"` Scope string `json:"scope,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` IDToken string `json:"id_token,omitempty"` State string `json:"-"` UserName string `json:"-"` }
GraphToken response data from ad server
func QueryToken ¶
func QueryToken(code, state string) (*GraphToken, error)
QueryToken get token from provider
**Example POST /{tenant}/oauth2/v2.0/token HTTP/1.1 Host: https://login.microsoftonline.com Content-Type: application/x-www-form-urlencoded
client_id=6731de76-14a6-49ae-97bc-6eba6914391e &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr... &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F &grant_type=authorization_code &client_secret=JqQX2PNo9bpM0uEihUPzyrh
func RefreshToken ¶
func RefreshToken(token *GraphToken) (*GraphToken, error)
RefreshToken refresh token if access token is expired
**Refresh Example: POST /{tenant}/oauth2/v2.0/token HTTP/1.1 Host: https://login.microsoftonline.com Content-Type: application/x-www-form-urlencoded
client_id=6731de76-14a6-49ae-97bc-6eba6914391e &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read &refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq... &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F &grant_type=refresh_token &client_secret=JqQX2PNo9bpM0uEihUPzyrh
type GraphUser ¶
type GraphUser struct { ID string `json:"id,omitempty"` Enabled bool `json:"accountEnabled,omitempty"` UserType string `json:"userType,omitempty"` DisplayName string `json:"displayName,omitempty"` GivenName string `json:"givenName,omitempty"` AboutMe string `json:"aboutMe,omitempty"` Mail string `json:"mail,omitempty"` JobTitle string `json:"jobTitle,omitempty"` MobilePhone string `json:"mobilePhone,omitempty"` CompanyName string `json:"companyName,omitempty"` Department string `json:"department,omitempty"` BusinessPhones []string `json:"businessPhones,omitempty"` }
GraphUser from microsoft Graph API
func GetUserProfile ¶
func GetUserProfile(sessID string, token *GraphToken) (*GraphUser, error)
GetUserProfile request user profile by access token