mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-16 00:49:26 +01:00
795a8705c3
Documentation on https://github.com/42wim/matterbridge/wiki/MS-Teams-setup
2.0 KiB
2.0 KiB
msauth
Introduction
Very simple package to authorize applications against Microsoft identity platform.
It utilizes v2.0 endpoint so that it can authorize users using both personal (Microsoft) and organizational (Azure AD) account.
Usage
Device authorization grant
const (
= "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
tenantID = "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY"
clientID = "token_cache.json"
tokenCachePath )
var scopes = []string{"openid", "profile", "offline_access", "User.Read", "Files.Read"}
:= context.Background()
ctx := msauth.NewManager()
m .LoadFile(tokenCachePath)
m, err := m.DeviceAuthorizationGrant(ctx, tenantID, clientID, scopes, nil)
tsif err != nil {
.Fatal(err)
log}
.SaveFile(tokenCachePath)
m
:= oauth2.NewClient(ctx, ts)
httpClient ...
Client credentials grant
const (
= "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
tenantID = "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY"
clientID = "ZZZZZZZZZZZZZZZZZZZZZZZZ"
clientSecret )
var scopes = []string{msauth.DefaultMSGraphScope}
:= context.Background()
ctx := msauth.NewManager()
m , err := m.ClientCredentialsGrant(ctx, tenantID, clientID, clientSecret, scopes)
tsif err != nil {
.Fatal(err)
log}
:= oauth2.NewClient(ctx, ts)
httpClient ...
Authorization code grant
- OAuth 2.0 authorization code grant flow
- Not yet implemented.