graph

package
v0.0.0-...-daeb405 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadRequest is a 400 http error.
	ErrBadRequest = errors.New("bad request")
	// ErrNotFound is a 404 http error.
	ErrNotFound = errors.New("not found")
	// ErrUnknown is an unknown http error.
	ErrUnknown = errors.New("unknown error")
)

Functions

func OAuthClient

func OAuthClient(ctx context.Context, scopeURL string, c *Credentials) *http.Client

OAuthClient returns an authenticated httpClient using the provided credentials.

*Specific to the OAuth2 client credentials grant flow implemented by the Microsoft Identity Platform* The scopeURL is always concatenated with /.default.

From Microsoft Graph API documentation (https://docs.microsoft.com/en-us/graph/auth-v2-service): For Microsoft Graph, the value is https://graph.microsoft.com/.default. This value informs the Microsoft identity platform endpoint that of all the application permissions you have configured for your app, it should issue a token for the ones associated with the resource you want to use.

Types

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	Users *UsersService
	// contains filtered or unexported fields
}

A Client handles communication with the Microsoft Graph REST API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient creates a Client using the provided httpClient. If nil is provided, a default httpClient with a default timeout value is created. Note that the default client has no way of authenticating itself against the Microsoft Graph API. A convenience function is provided just for that: NewClientAuthenticated.

func NewClientAuthenticated

func NewClientAuthenticated(c *Credentials) *Client

NewClientAuthenticated creates an authenticated Client.

func (*Client) Version

func (c *Client) Version() string

Version returns the client version.

type Credentials

type Credentials struct {
	ClientID     string
	ClientSecret string
	TenantID     string
}

Credentials are used by OAuthClient.

type User

type User struct {
	BusinessPhones    []string `json:"businessPhones"`
	DisplayName       string   `json:"displayName"`
	GivenName         string   `json:"givenName"`
	ID                string   `json:"id"`
	JobTitle          string   `json:"jobTitle"`
	Mail              string   `json:"mail"`
	MobilePhone       string   `json:"mobilePhone"`
	OfficeLocation    string   `json:"officeLocation"`
	PreferredLanguage string   `json:"preferredLanguage"`
	Surname           string   `json:"surname"`
	UserPrincipalName string   `json:"userPrincipalName"`
}

User represents a Azure AD work or school user account or a Microsoft account in Microsoft Graph.

type UsersService

type UsersService service

UsersService handles communication with the users related methods of the Microsoft Graph API.

func (*UsersService) Get

func (s *UsersService) Get(ctx context.Context, id string) (*User, error)

Get returns a User.

func (*UsersService) List

func (s *UsersService) List(ctx context.Context) ([]User, error)

List returns a slice of Users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL