dashed-slug.net › Forums › General discussion › [Feature Request] API Key Auth instead of Login Creds
Tagged: api, authentication, request
- This topic has 24 replies, 2 voices, and was last updated 5 years, 8 months ago by Anonymous.
-
AuthorPosts
-
March 27, 2019 at 9:35 am #6069AnonymousInactive
Whats the ugly path for the get_transactions? https://example.com/?__wallets_apiversion=3&__wallets_action=get_transactions how to add these values?: /SYMBOL/COUNT/FROM from the fancy path
March 28, 2019 at 11:28 am #6072alexgKeymasterAbout your question regarding transactions, here’s a complete example:
This would retrieve the first 10 BTC transactions. Don’t forget to add authentication parameters to your call.
You can always observe the XHR requests in your browser to see how the plugin does it.
This is where the GET parameters get passed into the PHP API:
https://github.com/dashed-slug/wallets/blob/4.2.0/includes/json-api.php#L1157-L1168
And the relevant PHP API:
with regards
April 10, 2019 at 11:23 am #6116AnonymousInactiveHi Alex,
do you have an ETA when the user_id is reported by the get nonce json call?
Regards
PhilippApril 10, 2019 at 11:47 am #6117alexgKeymasterHi Phillip,
Looking into this a bit further:
The
get_nonces
API call can by design only be performed by a logged-in user (i.e. with the cookies method, going through wp-login.php). This is typically done by a browser but does not have to be.My original intention was to be able to display the
user_id
andapi_key
with the[wallets_api_key]
shortcode, so that the user is then able to enter it into some other application and grant access. But the user must first login to the website to obtain this information.I am curious, what your login workflow would be? If the user can already login, what’s the use of having a user_id and key? What type of credential would the user provide to your application via your UI?
April 10, 2019 at 11:57 am #6118AnonymousInactiveHi Alex,
as I wrote in the beginning I don’t want to store the login creds on the phone where our app runs on. The initial auth will be via login and then receive the API Key, UserID and nonces. All future requests are made with the API Key. Alternatively (which I would prefer as it is the standard for the most APIs) drop the need of the userID in the JSON API. So the authentication would be only done via the APIKey.
I hope it’S clear what I mean.
Regards
PhilippApril 10, 2019 at 12:02 pm #6119AnonymousInactiveThis is an example auth within the app:
This opens the in app browser and lets the user login then the automatic redirect to the get_nonces JSON api happens and the app takes the information and securely stores and encrypts them.
April 10, 2019 at 12:06 pm #6120alexgKeymasterDropping the user_id requirement is something that I would like to do, as it is the best solution. I hadn’t found an efficient way to do this yet but it is the correct solution.
As this will go into JSON API 4, I cannot provide an estimate. As a general rule I only provide estimates for defects, not new features, since it is impossible to estimate how long things take.
I will look into how to eliminate the requirement for a user_id argument and let you know.
with regards
April 10, 2019 at 12:12 pm #6121AnonymousInactiveOr just add the userID to the get_nonces api key as a little workaround so it’s working in the first place.
April 10, 2019 at 3:35 pm #6128alexgKeymasterHello,
I have modified version 3 of the JSON API in plugin version
4.2.1
. The__wallets_user_id
argument is now ignored. If you specify an API key in your calls, the effective user whose data is returned, is always the user who corresponds to the given API key.with regards
April 10, 2019 at 3:47 pm #6130AnonymousInactiveOK great thanks.
Regards
Philipp -
AuthorPosts
- You must be logged in to reply to this topic.