Skip to content

Connect-PowerBIServiceAccount provide _-Token_ parameter#427

Merged
leblocks merged 7 commits intomasterfrom
Connect-PowerBIServiceAccount_support_bring_your_own_token_option
Feb 26, 2026
Merged

Connect-PowerBIServiceAccount provide _-Token_ parameter#427
leblocks merged 7 commits intomasterfrom
Connect-PowerBIServiceAccount_support_bring_your_own_token_option

Conversation

@leblocks
Copy link
Contributor

@leblocks leblocks commented Feb 8, 2026

Provide an option to bring your own token for authentication

@leblocks
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

case PowerBIProfileType.Certificate:
return await this.Authenticate(profile.UserName, profile.Thumbprint, profile.Environment, logger, settings);
case PowerBIProfileType.BringYourOwnToken:
return new PowerBIAccessToken { AccessToken = profile.AccessToken, };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough for customer? On the other hand, we return what has been passed in.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new authentication option to Connect-PowerBIServiceAccount that allows callers to supply their own JWT access token, propagating it through the profile/authentication flow so subsequent API calls can use it.

Changes:

  • Introduces a new BringYourOwnToken parameter set with -Token on Connect-PowerBIServiceAccount, including JWT lifetime validation.
  • Extends profile/authentication abstractions (IPowerBIProfile, PowerBIProfileType, AuthenticationFactorySelector) to support a BYOT login type.
  • Updates help documentation and adds unit tests for token-format/expiry validation and parameter-set binding behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/Modules/Profile/Commands.Profile/help/Connect-PowerBIServiceAccount.md Documents the new -Token parameter set and adds an example.
src/Modules/Profile/Commands.Profile/GetPowerBIAccessToken.cs Minor whitespace cleanup.
src/Modules/Profile/Commands.Profile/ConnectPowerBIServiceAccount.cs Adds BYOT parameter set and JWT validation prior to creating a profile.
src/Modules/Profile/Commands.Profile.Test/ConnectPowerBIServiceAccountTests.cs Adds tests covering malformed/expired/valid tokens and invalid parameter combinations.
src/Common/Common.Abstractions/PowerBIProfileType.cs Adds BringYourOwnToken enum value.
src/Common/Common.Abstractions/PowerBIProfile.cs Adds AccessToken storage and a BYOT constructor.
src/Common/Common.Abstractions/Interfaces/IPowerBIProfile.cs Adds AccessToken to the profile interface.
src/Common/Commands.Common/Commands.Common.csproj Adds Microsoft.IdentityModel.JsonWebTokens dependency.
src/Common/Commands.Common/AuthenticationFactorySelector.cs Adds BYOT handling in Authenticate(profile, ...).
src/Common/Commands.Common.Test/TestProfile.cs Implements new AccessToken property required by IPowerBIProfile.
Directory.Packages.props Centrally pins Microsoft.IdentityModel.JsonWebTokens version.
.editorconfig Enables trimming trailing whitespace.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


### Example 5
```powershell
PS C:\> Connect-PowerBIServiceAccount -Token eyJhbGciOiJIUzI1NiJ9.eyJ0ZXN0X2NsYWltIjp0cnVlLCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSIsImV4cCI6MjcxNzQ0Njc4NSwiaWF0IjoxNzcwNzE4Nzg1fQ.nOXgwieIpeFB9Svxxt6Z4_RkWVWSiVJcxbBzlPTaQJQ
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example includes a full JWT-like token inline. Even if it’s a dummy token, it’s safer to either clearly label it as fake and/or truncate/redact it to discourage copying secrets into command history.

Suggested change
PS C:\> Connect-PowerBIServiceAccount -Token eyJhbGciOiJIUzI1NiJ9.eyJ0ZXN0X2NsYWltIjp0cnVlLCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSIsImV4cCI6MjcxNzQ0Njc4NSwiaWF0IjoxNzcwNzE4Nzg1fQ.nOXgwieIpeFB9Svxxt6Z4_RkWVWSiVJcxbBzlPTaQJQ
PS C:\> Connect-PowerBIServiceAccount -Token eyJhbGciOiJIUzI1NiJ9.fake_payload_and_signature_redacted_for_example

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
Microsoft.PowerBI.Commands.Admin 83% 60%
Microsoft.PowerBI.Commands.Capacities 97% 55%
Microsoft.PowerBI.Commands.Common 38% 25%
Microsoft.PowerBI.Commands.Common.Test 46% 65%
Microsoft.PowerBI.Commands.Data 65% 57%
Microsoft.PowerBI.Commands.Profile 23% 20%
Microsoft.PowerBI.Commands.Profile.Test 7% 0%
Microsoft.PowerBI.Commands.Reports 30% 14%
Microsoft.PowerBI.Commands.Workspaces 94% 91%
Microsoft.PowerBI.Commands.Workspaces.Test 0% 0%
Microsoft.PowerBI.Common.Abstractions 54% 38%
Microsoft.PowerBI.Common.Api 4% 3%
Microsoft.PowerBI.Common.Authentication 2% 0%
Microsoft.PowerBI.Common.Client 31% 17%
Summary 25% (1887 / 7445) 24% (445 / 1850)

Minimum allowed line rate is 25%

@leblocks leblocks merged commit f2d7eb7 into master Feb 26, 2026
5 checks passed
@leblocks leblocks deleted the Connect-PowerBIServiceAccount_support_bring_your_own_token_option branch February 26, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants