Troubleshooting error - invalid email-id and username or password while executing the script for reporting APIs
This article applies to:
- OS: Windows OS running PowerShell
- Product edition: inSync Cloud
Problem description
The following error is displayed on running the script to generate the API reports:
Invalid email-id/username or password.
Cause
- Email address mismatch (case sensitive)
- Access token for inSync APIs is expired
Resolution
For email address mismatch:
- Log on to inSync Management Console.
- Go to Settings > Access Token tab.
- Under Access token for inSync APP, copy the email address displayed against Generated by field.
- Replace the <username> in the script with the email address copied in the earlier step.
For example, you need to replace the <username> in bold text in the code snippet below:
Example:
$secpasswd = ConvertTo-SecureString "<Access-Token>" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ('<username>’, $secpasswd)
$user = Invoke-RestMethod -Method 'Get' -uri "https://<On-prem-Master-FQDN-OR-IP:port>/api/reports/v1/users" -Credential $Cred
See: How to create custom reports in CSV using PowerShell and Rest API? for more information.
For expired access token:
- Log on to inSync Management Console.
- Go to Settings > Access Token tab.
- Click Create New Token and click Continue on the Create New Token dialogue. This will expire the earlier token.
- You can optionally set the expiry date and click Create.
- Copy the newly generated token and replace the access token boldfaced in the script example below:
Example:
$secpasswd = ConvertTo-SecureString "<Access-Token>" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ('<username>’, $secpasswd)
$user = Invoke-RestMethod -Method 'Get' -uri "https://<On-prem-Master-FQDN-OR-IP:port>/api/reports/v1/users" -Credential $Cred
Verification
Verify if you can successfully execute the PowerShell command.