generated from sitecorelabs/xmcloud-foundation-head-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
New-EdgeToken.ps1
25 lines (21 loc) · 1009 Bytes
/
New-EdgeToken.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# parse the sitecore.json file for the XM Cloud plugin version
[CmdletBinding(DefaultParameterSetName = 'FromArgs')]
param (
[Parameter(Mandatory)]
[string]$EnvironmentId
)
$ErrorActionPreference = "Stop"
$XmCloudDeployApi = (Get-Content "$PSScriptRoot\.sitecore\user.json" | ConvertFrom-Json).endpoints.xmCloud.host
$XmCloudDeployAccessToken = (Get-Content "$PSScriptRoot\.sitecore\user.json" | ConvertFrom-Json).endpoints.xmCloud.accessToken
$Headers = @{"Authorization" = "Bearer $XmCloudDeployAccessToken" }
$URL = @(
"$($XmCloudDeployApi)api/environments/v1"
$EnvironmentId
'obtain-edge-token'
)
$Response = Invoke-RestMethod ($URL -join '/') -Method 'GET' -Headers $Headers -Verbose
$AccessToken = $Response.apiKey
$EdgeUrl = "$($Response.edgeUrl)/api/graphql/ide"
Write-Host "Launching Edge GraphQL IDE"
Write-Host "Add { ""X-GQL-Token"" : ""$AccessToken"" } to the HTTP HEADERS tab at the bottom-left of the screen to write queries against your content"
Start-Process $EdgeUrl