Connect-PnPOnline Error: "Token request failed"
Hi friends,
This will install the necessary module
If the output of the above contains your key, then you can check the validity of it. If not then it must have expired.
I was working on PnP Powershell and while trying to connect it to the site via AppId & AppSecret or ClientId & ClientSecret I started getting the error: "Connect-PnPOnline: Token request failed". After a lot of googling, I got the solution or say the root cause of the issue.
Find out the expiration dates of the SharePoint Add-ins installed to the Office 365 tenancy
When a SharePoint add-in is created, the ClientId and ClientSecret is valid for the duration of 1 year, after that you need to renew the ClientSecret. To verify the valid keys in your tenant execute the below code
Step 1: Install the MSOnline module
To get the information, you need to install the MSOnline module. To install open the Powershell application with the Administrator rights and execute the below command
Step 2: Check for the valid ClientId's
Execute the below code in the Powershell. This will return all the valid ClientID's. Below script will filter the following
- All Microsoft's own application
- All non-SharePoint Add-ins
If the output of the above contains your key, then you can check the validity of it. If not then it must have expired.
Step 3: Generate new ClientSecret for SharePoint Add-in
The below code will help you to generate the new ClientSecret for the specific Client ID.
Hope this will help you to quickly resolve the issue
Happy Coding
#Microsoft #Powershell #SharePointAddin #SharePointWidgets
Comments
Post a Comment