Skip to main content

PowerPlatformTokenProvider

  • Namespace: PPDS.Auth.Credentials
  • Assembly: PPDS.Auth
  • Kind: Class
  • Implements: IPowerPlatformTokenProvider, IDisposable

Summary

Provides access tokens for Power Platform REST APIs using MSAL. Supports user-delegated (interactive, device code) and application (client credentials) flows.

Members

Constructors

PowerPlatformTokenProvider(CloudEnvironment cloud, string tenantId, string username, string homeAccountId)

PowerPlatformTokenProvider(CloudEnvironment cloud, string tenantId, string username, string homeAccountId)

Creates a provider for user-delegated authentication (interactive/device code).

  • Param cloud: The cloud environment.

  • Param tenantId: Optional tenant ID.

  • Param username: Optional username for silent auth lookup.

  • Param homeAccountId: Optional MSAL home account identifier.

PowerPlatformTokenProvider(string applicationId, string clientSecret, string tenantId, CloudEnvironment cloud)

PowerPlatformTokenProvider(string applicationId, string clientSecret, string tenantId, CloudEnvironment cloud)

Creates a provider for service principal (client credentials) authentication.

  • Param applicationId: The application (client) ID.

  • Param clientSecret: The client secret.

  • Param tenantId: The tenant ID.

  • Param cloud: The cloud environment.

Methods

Dispose

void Dispose()

(inherited from System.IDisposable.Dispose)

FromProfile

PowerPlatformTokenProvider FromProfile(AuthProfile profile)

Creates a provider from an auth profile for user-delegated authentication.

  • Param profile: The auth profile.

  • Returns: A new provider instance.

FromProfileWithSecret

PowerPlatformTokenProvider FromProfileWithSecret(AuthProfile profile, string clientSecret)

Creates a provider from an auth profile with client secret for SPN authentication.

  • Param profile: The auth profile.

  • Param clientSecret: The client secret.

  • Returns: A new provider instance.

GetFlowApiTokenAsync

Task<PowerPlatformToken> GetFlowApiTokenAsync(CancellationToken cancellationToken)

Acquires an access token for the Flow API using the correct service.powerapps.com scope. Use this method for Flow API and Connections API operations, which require the service.powerapps.com audience rather than api.flow.microsoft.com.

  • Param cancellationToken: Cancellation token.

  • Returns: A valid access token with service.powerapps.com audience.

GetPowerAppsTokenAsync

Task<PowerPlatformToken> GetPowerAppsTokenAsync(CancellationToken cancellationToken)

Acquires an access token for the Power Apps API. Resource: https://api.powerapps.com (varies by cloud).

  • Param cancellationToken: Cancellation token.

  • Returns: A valid access token.

GetPowerAutomateTokenAsync

Task<PowerPlatformToken> GetPowerAutomateTokenAsync(CancellationToken cancellationToken)

Acquires an access token for the Power Automate (Flow) API. Resource: https://api.flow.microsoft.com (varies by cloud).

  • Param cancellationToken: Cancellation token.

  • Returns: A valid access token.

GetTokenForResourceAsync

Task<PowerPlatformToken> GetTokenForResourceAsync(string resource, CancellationToken cancellationToken)

Acquires an access token for the specified Power Platform resource.

  • Param resource: The resource URL (e.g., https://api.powerapps.com).

  • Param cancellationToken: Cancellation token.

  • Returns: A valid access token.