Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

#msgraph-go Library for communication with Microsoft Graph API.

Library support

Currently supported are requests to:

  • basic user info
  • calendars

More request support may come soon. All exposed methods are subject to change.

Usage

To install the library into your project, add msgraph-go into your GOPATH:

$ go get github.com/jkrecek/msgraph-go

Then, in your go project, you can create graph client:

import "github.com/jkrecek/msgraph-go"

var exampleOAuthConfig = &oauth2.Config{
   ClientID: "YOUR_CLIENT_ID",
   RedirectURL: "https://localhost",
   Scopes: []string{
       "User.Read",
   },
   Endpoint: oauth2.Endpoint{
       AuthURL: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
       TokenURL: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
   },
}

exampleOAuthToken := &oauth2.Token{
   AccessToken: "YOUR_ACCESS_TOKEN",
   RefreshToken: "YOUR_REFRESH_TOKEN",
   Expiry: time.Now().Add(time.Hour), 
}


client := graph.NewClient(exampleOAuthConfig, exampleOAuthToken)

Both oauth2.Config and oauth2.Token are required to successfully authorize outgoing requests.

To make further requests, you can call method directly on client, for example:

...

client := graph.NewClient(exampleOAuthConfig, exampleOAuthToken)

me, err := client.GetMe()
if err != nil {
    log.Println(err)
}

_ = me.Id                   // Returns user id
_ = me.UserPrincipalName    // Returns user principal name, usually email address

About

Library for communication with Microsoft Graph API. This library is NOT complete.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages