Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions LogicAppConnectionAuth.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Param(
[string] $api = 'office365 | dropbox | dynamicscrmonline | etc.',
[string] $ConnectionName = 'YourConnectionName',
[string] $subscriptionId = '80d4fe69-xxxx-xxxx-a938-9250f1c8ab03',
[string] $ADobjectId = '59b2c08b-xxxx-xxxx-840a-2d6d1e19fe8a',
[bool] $createConnection = $false
)
#region mini window, made by Scripting Guy Blog
Expand Down Expand Up @@ -35,10 +34,6 @@ Login-AzureRmAccount

$subscription = Select-AzureRmSubscription -SubscriptionId $subscriptionId

#can try to automatically get objectId
# $user = Get-AzureRmADUser -Mail 'myemail@foo.com'
# $ADobjectId = $user.Id

#if the connection wasn't alrady created via a deployment
if($createConnection)
{
Expand All @@ -56,8 +51,6 @@ $parameters = @{
"redirectUrl"= "https://ema1.exp.azure.com/ema/default/authredirect"
}
}
$parameters.parameters[0].Add("objectId", $ADobjectid)
$parameters.parameters[0].Add("tenantId", $subscription.Tenant.TenantId)

#get the links needed for consent
$consentResponse = Invoke-AzureRmResourceAction -Action "listConsentLinks" -ResourceId $connection.ResourceId -Parameters $parameters -Force
Expand All @@ -72,9 +65,11 @@ $regex = '(code=)(.*)$'
Write-output "Received an accessCode: $code"

if (-Not [string]::IsNullOrEmpty($code)) {
$objectid = (Get-AzureRMADUser -Mail (Get-AzureRmContext).Account.Id).Id

$parameters = @{ }
$parameters.Add("code", $code)
$parameters.Add("objectId", $ADobjectid)
$parameters.Add("objectId", $objectid)
$parameters.Add("tenantId", $subscription.Tenant.TenantId)
# NOTE: errors ignored as this appears to error due to a null response

Expand Down