4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-19 04:52:31 +00:00

Add initial Microsoft Teams support

Documentation on https://github.com/42wim/matterbridge/wiki/MS-Teams-setup
This commit is contained in:
Wim
2019-12-26 23:12:28 +01:00
parent 3af0dc3b3a
commit 795a8705c3
3362 changed files with 229502 additions and 22 deletions

View File

@@ -0,0 +1,27 @@
package msauth
import (
"context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
"golang.org/x/oauth2/microsoft"
)
// ClientCredentialsGrant performs OAuth 2.0 client credentials grant and returns auto-refreshing TokenSource
func (m *Manager) ClientCredentialsGrant(ctx context.Context, tenantID, clientID, clientSecret string, scopes []string) (oauth2.TokenSource, error) {
config := &clientcredentials.Config{
ClientID: clientID,
ClientSecret: clientSecret,
TokenURL: microsoft.AzureADEndpoint(tenantID).TokenURL,
Scopes: scopes,
AuthStyle: oauth2.AuthStyleInParams,
}
var err error
ts := config.TokenSource(ctx)
_, err = ts.Token()
if err != nil {
return nil, err
}
return ts, nil
}