Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Anyone using python on API

8 REPLIES 8
Reply
Message 1 of 9
sten
605 Views, 8 Replies

Anyone using python on API

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

Tags (1)
8 REPLIES 8
Message 2 of 9
Redmond.D
in reply to: sten

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.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 9
sten
in reply to: Redmond.D

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).

Message 4 of 9
sten
in reply to: sten

I am still hoping that some on in Autodesk will pick this up.

Please provide a format of the strings sent to the server for login.
I have been able to log into other providers API using it.
For example: http://developer.axosoft.com/authentication
Their documentation was very easy to follow and login was a breeze.

I am pretty sure I am not the only Python user out there who would be interested.
Message 5 of 9
sten
in reply to: sten

still desperatly looking for clues.....

Message 6 of 9
ac
Explorer
in reply to: sten

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

 

Message 7 of 9
sten
in reply to: ac

Thank you for hint. Ill give that a try.
That could very well be my problem.
Message 8 of 9
gasevsm
in reply to: sten

We have a new section in the PLM 360 help describing v1 API Reference. My recommendation is to review that as it's a more straightforward authentication and authorization model than the approach you're trying to do via the v2 technical preview endpoints. In addition, I think you will make more progress in shorter time with using Python calling PLM API. If you have additional questions or comments, do not hesitate to drop me a private email.

Martin Gasevski | Fusion 360 Team Product Manager
Message 9 of 9
dkeeley
in reply to: gasevsm

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.

Post to forums  

Autodesk Design & Make Report