Golang Microsoft Graph API implementation
go-msgraph is a go lang implementation of the Microsoft Graph API. See https://developer.microsoft.com/en-us/graph/docs/concepts/overview
General
This implementation has been written to get various user, group and calendar details out of a Microsoft Azure Active Directory. Currently only READ-access is implemented, but you are welcome to add WRITE-support to it & backmerge it
Features
working & tested:
- list users, groups, calendars, calendarevents
- automatically grab & refresh token for API-access
- json-load the GraphClient struct & initialize it
- set timezone for full-day CalendarEvent
in progress:
- implement paging to load huge data-sets, currently limitted to one page, 999 entries
planned:
Example
To get your credentials visit: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal
graphClient, err := msgraph.NewGraphClient("<TenantID>", "<ApplicationID>", "<ClientSecret>")
if err != nil {
fmt.Println("Credentials are probably wrong or system time is not synced: ", err)
}
fileContents, err := ioutil.ReadFile("./msgraph-credentials.json")
var graphClient msgraph.GraphClient
err = json.Unmarshal(fileContents, &graphClient)
users, err := graphClient.ListUsers()
user, err := graphClient.GetUser("humpty@contoso.com")
groups, err := graphClient.ListGroups()
groupMembers, err := groups[0].ListMembers()
calendars, err := user.ListCalendars()
msgraph.FullDayEventTimeZone, _ = time.LoadLocation("Europe/Vienna")
startTime := time.Now()
endTime := time.Now().Add(time.Hour * 24 * 7)
events, err := graphClient.ListCalendarView("alice@contoso.com", startTime, endTime)
Installation
Using go get
$ go get github.com/open-networks/go-msgraph
You can use go get -u
to update the package.
Documentation
For docs, see http://godoc.org/github.com/open-networks/go-msgraph or run:
$ godoc github.com/open-networks/go-msgraph