Since I’ve launched CIPP I’ve been getting a load of questions concerning the Safe Utility Mannequin, some of the widespread occurrences occurs to be that customers in some way don’t get their tokens setup fully, and must retrieve these once more.
Setting all of the permissions and such is usually a trouble so that you don’t need to recreate your complete app. This script permits you to retrieve new tokens, you need to use these tokens in CIPP or completely different places.
When utilizing CIPP, you solely want to do that as soon as because it takes over administration of the tokens and refreshes them every week mechanically.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
$ApplicationId = 'ApplicationID'
$ApplicationSecret = 'Secret' | Convertto-SecureString -AsPlainText -Power
$TenantID = 'YourTenantID'
$credential = New-Object System.Administration.Automation.PSCredential($ApplicationId, $ApplicationSecret)
$token = New-PartnerAccessToken -ApplicationId $ApplicationID -Scopes 'https://api.partnercenter.microsoft.com/user_impersonation' -ServicePrincipal -Credential $credential -Tenant $TenantID -UseAuthorizationCode
$Exchangetoken = New-PartnerAccessToken -ApplicationId 'a0c73c16-a7e3-4564-9a95-2bdf47383716' -Scopes 'https://outlook.office365.com/.default' -Tenant $TenantID -UseDeviceAuthentication
Write-Host "================ Secrets and techniques ================"
Write-Host "`$ApplicationId = $($applicationID)"
Write-Host "`$ApplicationSecret = $($ApplicationSecret)"
Write-Host "`$TenantID = $($tenantid)"
write-host "`$RefreshToken = $($token.refreshtoken)" -ForegroundColor Blue
write-host "`$ExchangeRefreshToken = $($ExchangeToken.Refreshtoken)" -ForegroundColor Inexperienced
Write-Host "================ Secrets and techniques ================"
Write-Host " SAVE THESE IN A SECURE LOCATION "
|
As all the time, Pleased PowerShelling 🙂