summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/matterbridge/msgraph.go/msauth/README.md
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-03-08 17:08:18 +0100
committerGitHub <noreply@github.com>2020-03-08 17:08:18 +0100
commit9785edd26366be8eb11c2435f50f90a5c8eea7fc (patch)
treee8e236b5b273e7535c607507cc059f3b957068a1 /vendor/github.com/matterbridge/msgraph.go/msauth/README.md
parent2a0bc11b684f63305258e338c5f1d0e91eb24414 (diff)
downloadmatterbridge-msglm-9785edd26366be8eb11c2435f50f90a5c8eea7fc.tar.gz
matterbridge-msglm-9785edd26366be8eb11c2435f50f90a5c8eea7fc.tar.bz2
matterbridge-msglm-9785edd26366be8eb11c2435f50f90a5c8eea7fc.zip
Remove replace directives and use own fork to make go get work again (#1028)
See https://github.com/golang/go/issues/30354 go get doesn't honor the go.mod replace options.
Diffstat (limited to 'vendor/github.com/matterbridge/msgraph.go/msauth/README.md')
-rw-r--r--vendor/github.com/matterbridge/msgraph.go/msauth/README.md70
1 files changed, 70 insertions, 0 deletions
diff --git a/vendor/github.com/matterbridge/msgraph.go/msauth/README.md b/vendor/github.com/matterbridge/msgraph.go/msauth/README.md
new file mode 100644
index 00000000..43aead20
--- /dev/null
+++ b/vendor/github.com/matterbridge/msgraph.go/msauth/README.md
@@ -0,0 +1,70 @@
+# 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
+
+- [OAuth 2.0 device authorization grant flow]
+
+```go
+const (
+ tenantID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
+ clientID = "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY"
+ tokenCachePath = "token_cache.json"
+)
+
+var scopes = []string{"openid", "profile", "offline_access", "User.Read", "Files.Read"}
+
+ ctx := context.Background()
+ m := msauth.NewManager()
+ m.LoadFile(tokenCachePath)
+ ts, err := m.DeviceAuthorizationGrant(ctx, tenantID, clientID, scopes, nil)
+ if err != nil {
+ log.Fatal(err)
+ }
+ m.SaveFile(tokenCachePath)
+
+ httpClient := oauth2.NewClient(ctx, ts)
+ ...
+```
+
+### Client credentials grant
+
+- [OAuth 2.0 client credentials grant flow]
+
+```go
+const (
+ tenantID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
+ clientID = "YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY"
+ clientSecret = "ZZZZZZZZZZZZZZZZZZZZZZZZ"
+)
+
+var scopes = []string{msauth.DefaultMSGraphScope}
+
+ ctx := context.Background()
+ m := msauth.NewManager()
+ ts, err := m.ClientCredentialsGrant(ctx, tenantID, clientID, clientSecret, scopes)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ httpClient := oauth2.NewClient(ctx, ts)
+ ...
+```
+
+### Authorization code grant
+
+- [OAuth 2.0 authorization code grant flow]
+- Not yet implemented.
+
+[Microsoft identity platform]: https://docs.microsoft.com/en-us/azure/active-directory/develop/
+[v2.0 endpoint]: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-overview
+[OAuth 2.0 device authorization grant flow]: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code
+[OAuth 2.0 client credentials grant flow]: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow
+[OAuth 2.0 authorization code grant flow]: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow \ No newline at end of file