entra

package
v1.88.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package entra obtains Microsoft Entra ID (Azure AD) access tokens for app-only calls to Microsoft APIs such as Microsoft Graph.

A failed token request carries its form, client assertion included, in the error's HTTP context; services logging errors should mask the request bodies of TokenUrl's endpoints.

Index

Constants

View Source
const (
	DefaultAuthorityHost = "login.microsoftonline.com"

	// FederatedAudience is the audience Entra requires of an external token
	// presented through a federated identity credential.
	FederatedAudience = "api://AzureADTokenExchange"

	// ScopeMicrosoftGraph requests the application permissions granted to the
	// app on Microsoft Graph; app-only tokens take only ".default" scopes.
	ScopeMicrosoftGraph = "https://graph.microsoft.com/.default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...entra_config.Option) *Client

func (*Client) NewClientAssertionTokenSource

func (c *Client) NewClientAssertionTokenSource(
	ctx context.Context,
	tenantId string,
	clientId string,
	scopes []string,
	assertion client_assertion_token_source.AssertionFunc,
) (token_source.TokenSource, error)

NewClientAssertionTokenSource returns a caching token source for the app clientId in the tenant tenantId, authenticating with assertions from assertion.

func (*Client) NewGoogleFederatedTokenSource

func (c *Client) NewGoogleFederatedTokenSource(
	ctx context.Context,
	gcpClient *gcp.Client,
	tenantId string,
	clientId string,
	scopes []string,
) (token_source.TokenSource, error)

NewGoogleFederatedTokenSource returns a caching token source that authenticates without a secret, presenting the ID token of the GCP runtime's service account. The app registration needs a federated identity credential with issuer https://accounts.google.com, the service account's numeric unique id as subject, and FederatedAudience as audience. A multi-tenant app uses the same credential in every tenant that has consented to it.

func (*Client) TokenUrl

func (c *Client) TokenUrl(tenantId string) string

TokenUrl returns the v2.0 token endpoint of the tenant identified by tenantId (a GUID or a verified domain).

Directories

Path Synopsis
types
token_source/client_assertion_token_source
Package client_assertion_token_source mints Microsoft Entra ID access tokens with the OAuth 2.0 client credentials grant, proving the application's identity with a JWT client assertion rather than a client secret.
Package client_assertion_token_source mints Microsoft Entra ID access tokens with the OAuth 2.0 client credentials grant, proving the application's identity with a JWT client assertion rather than a client secret.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL