I am trying to connect to the API using python but am having some difficulty.
I have cleared the Oxygen hurdle, but have a hard time understanding the OxygenLoginCredentials as described in Step 6.
I am a little confused about the header example shown, there seems to be unicode mixed in.
Is that a arifact of the help viewer or how the validation header is supposed to look.
I looked at the java and C# exampels given but a hard time following the code.
I hope someone out there can give me a few hints on how to move beyond this. I don't really want to install java or C#.
Thanks
I don't have much experience with Python, but I will offer whatever help I can. Ideally, you want to have a Python library that does the Oauth operations for you.
In the example JSON for step 6, the \u003d is the = character. Some of the JSON libraries escape this character (see this posting for more info). It has nothing to do with Unicode, they just don't want the = character showing up inside a string value.
I'm not sure if PLM 360 allows the = sign or not. The safe approach is to replace = with \u003d.
I am using a Oauth library and I have successfully been able to use it to log on to other vendors REST api.
The problem is that they all seem a little different.
What helped me out in other cases was an example of the complete https://... string needed to log in (with all the necessary encodings applied).
I have done this in PHP and also had some trouble with step 6 and 7.
My main problem was that I didn't know, that the tenant name must be in lower case in URLs when signing and uppercase in the OxygenLoginCredentials.
With that in place login was not a problem.
I don't know how to do it in Python, but here is what I have done in PHP using the OAuth and curl library.
$tenant = 'MYTENANTNAME';
$conskey = 'consumer_key';
$conssec = 'consumer_secret';
$access_token = 'access_token_previously_obtained';
$access_token_secret = 'access_token_secret_previously_obtained';
// Login URL (note that tenant MUST be lowercase)
$login_url = 'https://' strtolower($tenant) . '.autodeskplm360.net/api/v2/authentication/oxygen-login';
// Create OAuth authorization signature string
$oauth = new OAuth($conskey, $conssec, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
$oauth->setToken($access_token, $access_token_secret);
$authorization = $oauth->getRequestHeader('POST', $login_url);
// Create OxygenLoginCredentials JSON object (note that tenant MUST be uppercase)
$LoginCredentials['customerId'] = strtoupper($tenant);
$LoginCredentials['validation'] = $authorization;
$LoginCredentials_json = json_encode($LoginCredentials);
// Send the request to PLM
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $LoginCredentials_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json')
);
$result = curl_exec($ch); // result is a JSON object
curl_close($ch);
Cheers,
Anders
Hi,
I have a working script for the v1 API authentication using PHP. If anyone is interested PM me and I'll send them a copy.
David.
Can't find what you're looking for? Ask the community or share your knowledge.