Skip to content
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
12 changes: 11 additions & 1 deletion internal/graph/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"net/http"
"net/url"
"os"
"strings"
"time"

Expand All @@ -21,9 +22,18 @@ var (
// It can be overridden for testing.
GraphBaseURL = "https://graph.microsoft.com/v1.0"
// AuthURL is the base URL for OAuth2 authentication.
AuthURL = "https://login.microsoftonline.com/common/oauth2/v2.0"
// Supports MOG_TENANT_ID env var for single-tenant apps.
AuthURL = initAuthURL()
)

func initAuthURL() string {
tenant := os.Getenv("MOG_TENANT_ID")
if tenant == "" {
tenant = "common"
}
return "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0"
}

// Client defines the interface for Microsoft Graph API operations.
type Client interface {
Get(ctx context.Context, path string, query url.Values) ([]byte, error)
Expand Down