From 0a111cd9dfae0590f83a511cf3ab4bf879ea24c5 Mon Sep 17 00:00:00 2001 From: Danny Adams Date: Wed, 18 Jan 2023 23:33:18 -0500 Subject: [PATCH] Updates to the change log to address build times. --- CHANGELOG.md | 4 ++++ .../connector/graph/service_helper.go | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f24db17..7c78699ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Check if the user specified for an exchange backup operation has a mailbox. +### Changed + +- Beta Libraries are included in package. This can lead to long build times. + ## [v0.1.0] (alpha) - 2023-01-13 diff --git a/src/internal/connector/graph/service_helper.go b/src/internal/connector/graph/service_helper.go index 76ff54ad4..f6acdb9d0 100644 --- a/src/internal/connector/graph/service_helper.go +++ b/src/internal/connector/graph/service_helper.go @@ -10,6 +10,7 @@ import ( az "github.com/Azure/azure-sdk-for-go/sdk/azidentity" ka "github.com/microsoft/kiota-authentication-azure-go" khttp "github.com/microsoft/kiota-http-go" + beta "github.com/microsoftgraph/msgraph-beta-sdk-go" msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go" msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core" "github.com/pkg/errors" @@ -46,6 +47,25 @@ func CreateAdapter(tenant, client, secret string) (*msgraphsdk.GraphRequestAdapt auth, nil, nil, httpClient) } +// CreateBetaAdapter uses the provided credentials with the Kiota Azure Libraries. +// Used to access msgraph-beta-sdk-go specific functionality +func CreateBetaAdapter(tenant, client, secret string) (*beta.GraphRequestAdapter, error) { + cred, err := az.NewClientSecretCredential(tenant, client, secret, nil) + if err != nil { + return nil, errors.Wrap(err, "creating beta m365 client credentials") + } + + auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes( + cred, + []string{"https://graph.microsoft.com/.default"}, + ) + + httpClient := CreateHTTPClient() + + return beta.NewGraphRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient( + auth, nil, nil, httpClient) +} + // CreateHTTPClient creates the httpClient with middlewares and timeout configured func CreateHTTPClient() *http.Client { clientOptions := msgraphsdk.GetDefaultClientOptions()