Activated users and legal documents?

Howdy,
A user is created, set and activated using API. Will this user still be presented the legal documents at first connection to the plattorm?
Thanks.
--
Regards.
http://sl4.org/crocker.html

Ah ah, I missed the terms_accepted parameter. Suffice to set it to true then?
Thanks!

Unfortunately, no.
1. You need to impersonate themselves as this user.
POST /api/2/idp/ott
POST/api/2/idp/ott/login -> here you receive authorization cookie, and you need to use it for following requests
2. Take a list of legal documents.
GET /api/2/users/{{user_id}}/legal_documents
3. Sing them.
POST /api/2/users/{{user_id}}/legal_documents
4. Logout from user
GET /api/2/idp/logout
- Accedi per poter commentare
Stas Pavlov | Technology Evangelist
Acronis Developer Network | Acronis Cyber Cloud Solutions Portal | Acronis Cyber Platform
For more answers to your questions, try our Knowledge Base and Video Tutorials
Our mission is to create Customers and Partners success. Our management team welcomes your comments and suggestions on how we can improve the overall support we provide to you. Please send your comments, suggestions, or concerns to Managers or submit your feedback here.

Clear, thanks for the details!

Hi Stanislav,
When I'm trying to do that I succeeded to have my OTT but when I'm trying to login I have this error :
Invoke-RestMethod : {"error":{"code":500,"message":"Internal Server Error","details":{},"domain":"PlatformAccountServer","context":{}}}
Here how I proceeded :
$paramott = @"
{
"login": "$UserLogin",
"purpose": "user_login"
}
"@
$ott = Invoke-RestMethod -Method "POST" -Uri "${baseUrl}api/2/idp/ott" -Headers $headers -ContentType "application/json" -Body $paramott
$paramott2 = @"
{
"ott": "$ott",
}
"@
$ott2 = Invoke-RestMethod -Method "POST" -Uri "${baseUrl}api/2/idp/ott/login" -Headers $headers -ContentType "application/json" -Body $paramott2
My main goal is to sign Legal document as you mentionned on this topic.
- Accedi per poter commentare

You have non-needed "," in your second JSON
- Accedi per poter commentare
Stas Pavlov | Technology Evangelist
Acronis Developer Network | Acronis Cyber Cloud Solutions Portal | Acronis Cyber Platform
For more answers to your questions, try our Knowledge Base and Video Tutorials
Our mission is to create Customers and Partners success. Our management team welcomes your comments and suggestions on how we can improve the overall support we provide to you. Please send your comments, suggestions, or concerns to Managers or submit your feedback here.

I did the change but still the same error message :/
- Accedi per poter commentare

Ok I find out seems to work only if I put the data in plain text and doesn't works with a variable like :
$paramott2 = @"
{
"ott": "T1RUAQAAAPpHBQAAAAAAp8_RSsA6SWGg9GzppjtWGg=="
}
"@
To you have a trick to make it work with the variable that was define under into my main script ?
- Accedi per poter commentare

Also even if I succeeded to do the ott login I still having error message when I want to get the legal documents :
Command :
$Get_legal_documents = Invoke-RestMethod -Method "GET" -Uri "${baseUrl}api/2/users/$UserId/legal_documents" -Headers $headers -ContentType "application/json"
Error :
Invoke-RestMethod : {"error":{"code":401,"message":"OK","details":{},"domain":"PlatformAccountServer","context":{}}}
- Accedi per poter commentare

Adrien VANACKERE wrote:Ok I find out seems to work only if I put the data in plain text and doesn't works with a variable like :
$paramott2 = @"
{
"ott": "T1RUAQAAAPpHBQAAAAAAp8_RSsA6SWGg9GzppjtWGg=="}
"@
To you have a trick to make it work with the variable that was define under into my main script ?
ott text value is NOT the result of the rest call. ott value is $ott.ott in your variables
$ott = Invoke-RestMethod -Method "POST" -Uri "${baseUrl}api/2/idp/ott" -Headers $headers -ContentType "application/json" -Body $paramott
$paramott2 = @"
{
"ott": "$ott.ott"
}
"@
- Accedi per poter commentare
Stas Pavlov | Technology Evangelist
Acronis Developer Network | Acronis Cyber Cloud Solutions Portal | Acronis Cyber Platform
For more answers to your questions, try our Knowledge Base and Video Tutorials
Our mission is to create Customers and Partners success. Our management team welcomes your comments and suggestions on how we can improve the overall support we provide to you. Please send your comments, suggestions, or concerns to Managers or submit your feedback here.

Adrien VANACKERE wrote:Also even if I succeeded to do the ott login I still having error message when I want to get the legal documents :
Command :
$Get_legal_documents = Invoke-RestMethod -Method "GET" -Uri "${baseUrl}api/2/users/$UserId/legal_documents" -Headers $headers -ContentType "application/json"
Error :
Invoke-RestMethod : {"error":{"code":401,"message":"OK","details":{},"domain":"PlatformAccountServer","context":{}}}
You need to save authorization cookie to session from login call and use this session to be authorized for the following calls. A Pythin example below
#!/usr/bin/python
# -*- coding: utf-8 -*-
# ************************************************************
# Copyright © 2019-2020 Acronis International GmbH.
# This source code is distributed under MIT software license.
# ************************************************************
import requests # used for sending requests to the API
import json # used for manipulating JSON data
import pprint # used for formatting the output of JSON objects received in API responses
from base_operations import Config, BearerAuth, User
# Initialize config and read all required values form JSON config,
# an API client and a token files
cfg = Config(full=True)
user = User("user.json")
ott_request = {
"purpose": "user_login",
"login": f"{user.login}"
}
response = requests.post(
f'{cfg.base_url}api/2/idp/ott',
headers={**cfg.header, **{'Content-Type': 'application/json'}},
auth=BearerAuth(cfg.access_token),
data=json.dumps(ott_request)
)
if response.ok:
session = requests.Session()
response = session.post(
f'{cfg.base_url}api/2/idp/ott/login',
headers={**cfg.header, **{'Content-Type': 'application/json'}},
auth=BearerAuth(cfg.access_token),
data=response.text
)
if response.ok:
response = session.get(
f'{cfg.base_url}api/2/users/me',
headers=cfg.header
)
if response.ok:
print(f"The user {user.login} was successfully impersonated.")
print(json.dumps(response.json(), indent=2))
response = session.get(
f'{cfg.base_url}api/2/idp/logout',
headers=cfg.header
)
if response.ok:
print(f"The user {user.login} was successfully logged out.")
else:
pprint.pprint(response.json())
else:
pprint.pprint(response.json())
else:
pprint.pprint(response.json())
else:
pprint.pprint(response.json())
- Accedi per poter commentare
Stas Pavlov | Technology Evangelist
Acronis Developer Network | Acronis Cyber Cloud Solutions Portal | Acronis Cyber Platform
For more answers to your questions, try our Knowledge Base and Video Tutorials
Our mission is to create Customers and Partners success. Our management team welcomes your comments and suggestions on how we can improve the overall support we provide to you. Please send your comments, suggestions, or concerns to Managers or submit your feedback here.

Ok thanks for the help for that.
So now I have all my user information :
Under your talking about "here you receive authorization cookie, and you need to use it for following requests"
So which one should I use to get my legal document and should I use it in a body or straight into the get legal documents request ? Because I couldn't find the information neither in the RAML and in the developer.acronis.com/doc/account-management/v2/reference/index#/h
- Accedi per poter commentare

Cookies are part of the HTTP response. They are not in an HTML body. https://en.wikipedia.org/wiki/HTTP_cookie
In most cases, cookies are stored in a session like in my Python example. There is no uniqueness in Acronis API, it's a web-standard.
Thus you need to use the session for Invoke-RestMethod requests.
$paramott = @" { "login": "$UserLogin", "purpose": "user_login" } "@ $ott = Invoke-RestMethod -Method "POST" -Uri "${baseUrl}api/2/idp/ott" -Headers $headers -ContentType "application/json" -Body $paramott $paramott2 = @" { "ott": "$ott.ott" } "@ $user = Invoke-RestMethod -Method "POST" -Uri "${baseUrl}api/2/idp/ott/login" -Headers $headers -ContentType "application/json" -Body $paramott2 -SessionVariable session $Get_legal_documents = Invoke-RestMethod -Method "GET" -Uri "${baseUrl}api/2/users/$UserId/legal_documents" -Headers $headers -ContentType "application/json" -WebSession $session
- Accedi per poter commentare
Stas Pavlov | Technology Evangelist
Acronis Developer Network | Acronis Cyber Cloud Solutions Portal | Acronis Cyber Platform
For more answers to your questions, try our Knowledge Base and Video Tutorials
Our mission is to create Customers and Partners success. Our management team welcomes your comments and suggestions on how we can improve the overall support we provide to you. Please send your comments, suggestions, or concerns to Managers or submit your feedback here.
Stas Pavlov | Technology Evangelist
Acronis Developer Network | Acronis Cyber Cloud Solutions Portal | Acronis Cyber Platform
For more answers to your questions, try our Knowledge Base and Video Tutorials
Our mission is to create Customers and Partners success. Our management team welcomes your comments and suggestions on how we can improve the overall support we provide to you. Please send your comments, suggestions, or concerns to Managers or submit your feedback here.