Issue with generating authentication token for a specific tenant
I am experiencing difficulties when trying to generate an authentication token for a specific tenant to assign actions and access information within that tenant.
The issue is that when I initiate the token generation with the scope of my customer ID, it retrieves all the information from other clients.
Here is my current script:
# Création de l'authentification
$client_id = 'xxx-xxx-xxx-xxxx-xxxx'
$client_secret = 'xxxxxxx'
$base_url = 'https://eu-cloud.acronis.com'
$encoded_client_creds =[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${client_id}:${client_secret}"))
$basic_auth = @{
'Authorization' = 'Basic ' + $encoded_client_creds
}
$headers = @{
'Authorization' = 'Bearer '
}
# Get access token
$accesstoken = Invoke-RestMethod -Method Post -Uri "$base_url/api/2/idp/token" -Headers @{
'Content-Type' = 'application/x-www-form-urlencoded'
'Authorization' = $basic_auth.Authorization
} -Body @{
'grant_type' = 'client_credentials'
} | Select-Object -ExpandProperty access_token
$headers.Authorization += $accesstoken
# Get tenant parent ID
$tenant_parent_id = Invoke-RestMethod -Method Get -Uri "$base_url/api/2/clients/$client_id" -Headers $headers | Select-Object -ExpandProperty tenant_id
# Authentification customer
$CodeClient = "00971492"
# Get customer ID
$customerid = Invoke-RestMethod -Method GET -Uri "$base_url/api/2/search?text=$CodeClient&tenant=$tenant_parent_id" -Headers $headers -ContentType "application/json" | Select-Object -ExpandProperty items | Where-Object { $_.kind -eq "customer" } | Select-Object -ExpandProperty id
# Get customer access token
$headers_customer = @{
'Authorization' = 'Bearer '
}
$customeraccesstoken = Invoke-RestMethod -Method Post -Uri "$base_url/api/2/idp/token" -Headers @{
'Content-Type' = 'application/x-www-form-urlencoded'
} -Body @{
'grant_type' = "urn:ietf:params:oauth:grant-type:jwt-bearer"
'assertion' = ${accesstoken}
'scope' = "urn:acronis.com:tenant-id:${customerid}"
}
$headers_customer.Authorization += $customeraccesstoken.access_token
$policies = Invoke-RestMethod -Method Get -Uri "$base_url/api/policy_management/v4/policies" -Headers $headers_customer -ContentType "application/json"
Can you help me with this?

- Accedi per poter commentare

Hello Jose Pedro,
I opened a support ticket yesterday: [06239363] Issue with generating authentication token for a specific tenant [ref: !00D300Zcb.!500Vz01PSyE:ref].
Unfortunately, I received the following response from them:
Thank you for contacting Acronis Customer Central. My name is Imran and I will work with your ticket number 06239363. The case severity is C.
If I understand you correctly, you're facing an issue with token generation and authorizaton in Acronis Cyber Protect Cloud.
Well, it seems that this is a custom script and according to the Acronis Support Policies, the case falls under the out of scope of Support requests.
Hence, it not possible to provide further support.
I hope you understand.
Could you internally verify and furnish me with a response?
- Accedi per poter commentare

Hello!
I have informed our support about your reply. Please also respond to the email our support sent you, requesting an official and supported alternative workaround for that scenario.
Best regards.
- Accedi per poter commentare