Skip to content

Instantly share code, notes, and snippets.

@SibeeshVenu
Last active February 8, 2021 13:31
Show Gist options
  • Save SibeeshVenu/ea43ca7c4ce95fce204bb46137a3d02a to your computer and use it in GitHub Desktop.
Save SibeeshVenu/ea43ca7c4ce95fce204bb46137a3d02a to your computer and use it in GitHub Desktop.
$appName = "appname"
$apiName = "apiname"
$apiUri = "https://<tenantname>.onmicrosoft.com/api.access"
$secretStartDate = Get-Date
$secretEndDate = $secretStartDate.AddYears(10)
$myAdApp = New-AzureADApplication -DisplayName $appName -Oauth2AllowImplicitFlow $true -AvailableToOtherTenants $true
$myAdApi = New-AzureADApplication -DisplayName $apiName -AvailableToOtherTenants $true -KnownClientApplications $myAdApp.AppId -IdentifierUris $apiUri
$secret = New-AzureADApplicationPasswordCredential -ObjectId $myAdApi.ObjectId -CustomKeyIdentifier "GraphClientSecret" -StartDate $secretStartDate -EndDate $secretEndDate
$secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment