Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved exception handling when using -ValidateConnection with Connect-PnPOnline #3440

Merged

Conversation

KoenZomers
Copy link
Collaborator

Type

  • Bug Fix
  • New Feature
  • Sample
  • Optimization

Related Issues?

N/A

What is in this Pull Request ?

Changed the implementation of -ValidateConnection on Connect-PnPOnline so instead of throwing a generic unclear error message, it will return the actual reason of the validation failing. I.e. for an expired client secret it will now return:

Connect-PnPOnline: ProtocolError: The remote server returned an error: (401) Unauthorized. Response received: {"error":"invalid_client","error_description":"AADSTS7000222: The provided client secret keys for app 'xxxxxxx-5020-46db-a07d-b2c3ca1dd94d' are expired. Visit the Azure portal to create new keys for your app: https://aka.ms/NewClientSecret, or consider using certificate credentials for added security: https://aka.ms/certCreds.\r\nTrace ID: xxxxxx-8f14-49e2-9a49-525618731c00\r\nCorrelation ID: xxxxx-62fb-4524-a314-e50866339b51\r\nTimestamp: 2023-09-26 14:02:13Z","error_codes":[7000222],"timestamp":"2023-09-26 14:02:13Z","trace_id":"xxxxx-8f14-49e2-9a49-525618731c00","correlation_id":"xxxxx-62fb-4524-a314-e50866339b51","error_uri":"https://accounts.accesscontrol.windows.net/error?code=7000222"}

as opposed to how it is now:

Connect-PnPOnline: Exception has been thrown by the target of an invocation.

@gautamdsheth gautamdsheth merged commit e17b0c6 into pnp:dev Sep 26, 2023
1 check passed
@KoenZomers KoenZomers deleted the ClearerExceptionWhenValidatingConnect branch September 28, 2023 07:29
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.

2 participants