CanonicalLtd / maas-docs

Documentation for MAAS
https://docs.maas.io
Creative Commons Attribution Share Alike 4.0 International
26 stars 45 forks source link

Expand on API authentication #647

Open degville opened 7 years ago

degville commented 7 years ago

Expand on the current language examples, include curl example.

taken from #633:

it would be nice to get this enhancement as even if we know how to do it with python or whatever language you're using, it seems maas is not using the same naming convention in Oauth than other companies. Indeed, when using postman or some OAuth library, they're requiring the following elements:

Consumer Key. Consumer Secret. Access Token. Token Secret.

However, within maas we only use the following one:

Consumer Key. Key. Secret.

It is not clear what is what except for Consumer Key. Should we consider that secret is for Consumer Secret? Should we consider that key is for Token Secret? Should we consider that Access Token is the whole API Key build from the three previous part?

dooglz commented 6 years ago

For reference to anyone working ( #633 ) on this right now, here is a working settings I had using postman to talk to the maas REST API Your maas api key looks like "xxxxxxxxxxxxxxxxxx:yyyyyyyyyyyyyyyyyy:zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", which are your :: oauth params. Or in postman, your: Consumer Key : Access Token : Token Secret There is no Consumer Secret, this should be left blank. This isn't allowed in some frameworks (e.g php), in postman you can get away with entering a single space character.

Authorisation: Type: Oauth 1.0 Add to: Request Headers Keys Consumer Key: xxxxxxxxxxxxxxxxxx Consumer Secret: [literally a single whitespace character] Access Token: yyyyyyyyyyyyyyyyyy Token Secret: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Signature Method: PLAINTEXT

using the above I could request 127.0.0.1:5240/MAAS/api/2.0/machines/

There is a bug here, workaround is you have to request json. for some endpoints: 127.0.0.1:5240/MAAS/api/2.0/machines/dpywmk/?format=json

gnuoy commented 6 years ago

If you're using python you'll want to use libmaas but if some reason you don't, this worked for me: https://gist.github.com/gnuoy/c3775ebdf1b00f38fd36fa8b9014349c