Closed EwanValentine closed 3 years ago
Also interested in this!
The documentation for generating a PAT definitely needs improvement. You do not need a token to generate a PAT. You can simply call:
curl https://api.uphold.com/v0/me/tokens \
-X POST \
-H "Content-Type: application/json" \
-u "$EMAIL:$PASS" \
-d '{ "description": "Token for scripts" }'
The output will include your accessToken which can be used for your scripts.
Alternatively, if you have two factor authentication enabled, you can find your authentication method id with:
curl https://api.uphold.com/v0/me/authentication_methods \
-u "$EMAIL:$PASS"
The response will include an "id" field. Use that ID for $METHOD_ID below. The "$TOKEN" field will be the 6 digit code from your authenticator app or 000000 if using sandbox.
curl https://api.uphold.com/v0/me/tokens \
-X POST \
-H "Content-Type: application/json" \
-H "OTP-Method-Id: $METHOD_ID" \
-H "OTP-Token: $TOKEN" \
-u "$EMAIL:$PASS" \
-d '{ "description": "Token for scripts" }'
Then once again, you will have your access token in a JSON output.
Hey @EwanValentine! Sorry for the late response. I hope @oolubayo's comment may have helped already (thanks for chiming in, by the way!), but I thought I'd offer some additional context.
You're totally right that a PAT is currently the appropriate mechanism for personal scripting usage. Your confusion stems from the fact that, as @oolubayo pointed out, the documentation on PATs is rather lacking at the moment. Part of that is due to the fact that, as you said,
in order to create a PAT token, you seem to need a normal Bearer token. (...) you used to be able to use your username and password to create a PAT token but it was removed?
That removal (#161) was accurate at the time, but since then there have been changes in our platform that weren't reflected in the documentation. For the time being, I will restore the docs to match what currently works, and as soon as we finish the improvements under course, I will make sure to update the docs accordingly.
Thanks for the patience!
Hey, apologies if this is a stupid question, I wanted to script some trades with my Uphold account, as I'm not a corporate partner, PAT tokens seemed to be the best fit. However, in order to create a PAT token, you seem to need a normal Bearer token. However, I can't see how to get a Bearer token, unless you register an app, which I thought was for the corporate partners etc? I can see you used to be able to use your username and password to create a PAT token but it was removed?