Client Secrets authentication improvements#405
Draft
Foggy2 wants to merge 16 commits intoSCRT-HQ:mainfrom
Draft
Conversation
…SGSuite into programmatic-generation
…into build-debugging
…ass values for easier change tracking
… are stored on disk in module directories.
This was referenced Aug 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should address issue #345.
I have refactored the authentication code making improvements to the use of Client Secrets authentication.
I am working on putting together some Pester tests for this but I think Pester v5 is needed for the best outcome here. I haven't used Pester before so I am starting to have a look at what would be involved with migrating the existing tests to the newer version. Until then though, I am submitting this so that I can get some feedback in the interim.
This PR is based on the changes submitted in PR #402 and #404. As such, I have submitted this in draft status until those PRs are resolved.
Let me know your thoughts or any areas for improvement.
Changes include:
ClientSecretScopesconfiguration property. This property allows you to define a custom list of OAuth Scopes that are included in all authorization requests by default.ClientSecretScopes, PSGSuite will now incrementally request authorization for each additional scope as needed. This change enables all PSGSuite functions to be used with Client Secrets authentication.ClientSecretScopesconfiguration property.LocalServerCodeReceiverfor user authorization prompts. This replaces the deprecatedPromptCodeReceiver.https://www.googleapis.com/auth/userinfo.emailOAuth Scope when authorizing user accounts, regardless of theClientSecretScopesconfiguration.https://www.googleapis.com/auth/userinfo.emailscope.Get-PSGSuiteScope: Returns the OAuth scopes used by PSGSuite.Get-GSScope: Returns the OAuth scopes PSGSuite is authorized to access for a specified user when Client Secrets authentication is used.Get-PSGSuiteAuthenticationMethod: Returns the name of the currently configured authentication method (e.g.,Service-Account-JSON-Key,Service-Account-P12-Key,Client-Secrets-OAuth).Grant-GSScope: SupportsClient Secretsauthentication only. Requests authorization for PSGSuite to access the specified OAuth scopes.Revoke-GSScope: SupportsClient Secretsauthentication only. Revokes PSGSuite's authorization to access the specified OAuth scopes.Revoke-GSToken: SupportsClient Secretsauthentication only. Revokes PSGSuite's authorization to access the specified user account.Resolve-PSGSuiteScope: Resolves the provided OAuth scope identifiers to their corresponding OAuth scope values.PSGSuiteValidServiceValues: Validates Google API service names (e.g.,Google.Apis.Slides.v1.SlidesService).PSGSuiteValidFunctionValues: Validates public PSGSuite function names (e.g.,Get-GSPresentation).PSGSuiteValidScopeValues: Validates OAuth scopes used by PSGSuite (e.g.,https://www.googleapis.com/auth/drive).PSGSuiteValidScopeIdentifierValues: Validates all values fromPSGSuiteValidServiceValues,PSGSuiteValidFunctionValues, andPSGSuiteValidScopeValues.ClientSecretScopesproperty to the module configuration schema. This property defines the default OAuth scopes requested during Client Secrets authentication.Set-PSGSuiteConfig,Export-PSGSuiteConfigandGet-GSDecryptedConfigwith support for theClientSecretScopesconfiguration property.New-GoogleServicemoving the existing authentication code into new private functionsNew-ServiceAccountCredentialandNew-GoogleUserCredentialfor improved code re-usability.ci\templates\OAuthScopes.ps1that scans the PSGSuite source directory to automatically generate:Module\OAuthScopes.ps1(containing$script:_PSGSuiteScopesused byGet-PSGSuiteScope)Class\PSGSuiteValidServiceValues.ps1Class\PSGSuiteValidFunctionValues.ps1Class\PSGSuiteValidOAuthScopeValues.ps1Class\PSGSuiteValidScopeIdentifierValues.ps1