Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions drivers/microsoft.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package drivers

import (
"net/http"

"github.com/danilopolani/gocialite/structs"
"golang.org/x/oauth2/microsoft"
)

const microsoftDriverName = "microsoft"

func init() {
registerDriver(microsoftDriverName, MicrosoftDefaultScopes, MicrosoftUserFn, microsoft.AzureADEndpoint("common"), MicrosoftAPIMap, MicrosoftUserMap)
}

// MicrosoftUserMap is the map to create the User struct
var MicrosoftUserMap = map[string]string{
"id": "ID",
"givenName": "Username",
"displayName": "FullName",
"userPrincipalName": "Email",
}

// MicrosoftAPIMap is the map for API endpoints
var MicrosoftAPIMap = map[string]string{
"endpoint": "https://graph.microsoft.com",
"userEndpoint": "/v1.0/me",
}

// MicrosoftUserFn is a callback to parse additional fields for User
var MicrosoftUserFn = func(client *http.Client, u *structs.User) {}

// MicrosoftDefaultScopes contains the default scopes
var MicrosoftDefaultScopes = []string{"User.Read"}