clever-tools icon indicating copy to clipboard operation
clever-tools copied to clipboard

Add a `sign` command to generate oauth signatures

Open clementd-fretlink opened this issue 4 years ago • 4 comments

When manually interacting with the API via curl, generating signatures is a bit of a chore.

I needed to interact with the backup API earlier and ended up using @clevercloud/client from the node REPL to generate signatures. Having a command for that could make custom api calls way easier (be it to explore the API or issue custom calls not supported by the CLI).

One possible way would be to only output the authorization header contents, another would be generate a curl command ready to be copied. Issuing the HTTP call directly would be to tedious to implement on the arguments parsing side.

$ clever sign <METHOD> <URL> [<params>]
Authorization: xxx

# or
$ clever sign <METHOD> <URL> [<params>]
curl '<URL>' -X '<METHOD>' -H 'Authorization: xxx'

I think that would make interacting directly with the APi way easier

clementd-fretlink avatar Mar 31 '20 13:03 clementd-fretlink

(if you find it interesting, i can handle the implementation, i've tried a PoC here: https://github.com/CleverCloud/clever-tools/compare/master...divarvel:sign-command)

clementd-fretlink avatar Mar 31 '20 13:03 clementd-fretlink

This is a limitation from cURL, sadly.

Have you considered using a GUI like Postman? I know this doesn't address your CLI usage with cURL but it works great with oAuth v1 and our API.

Capture d’écran_2020-03-31_17-24-44

You setup the 4 oauth strings once and your done for all the other API fiddling/interacting you'll need to do...

hsablonniere avatar Mar 31 '20 15:03 hsablonniere

Well, i mostly use curl from scripts. That would make scripts easier to write, by reusing clever-tools when needed, instead of having to roll out a whole new executable.

clementd-fretlink avatar Mar 31 '20 15:03 clementd-fretlink

This is a limitation from cURL, sadly.

Have you considered using a GUI like Postman? I know this doesn't address your CLI usage with cURL but it works great with oAuth v1 and our API.

My (main) usage of the clever tools is made by a machine (I only use the clever tools as a human to debug things around) so this command would be very useful in a continuous deployment environment.

paulrbr-fl avatar Mar 31 '20 15:03 paulrbr-fl

Fixed with clever curl!

hsablonniere avatar Jun 26 '24 17:06 hsablonniere