I am writing a client app (reactjs) which consume some data in Frappe.
The idea is to call login API (username, password)
=> Then receive api_key + api_secret to make some API calls.
Which using token base authenticate as “token <api_key>:<api_secret>”
I followed some tutorials about user login and generate api_secret and has a login API.
The API look like:
However after login successfully and the above api return api_secret.
I used it to call others API but the api_secret is invalid.
Even I check the api_secret using the API “/api/method/frappe.auth.get_logged_user”, it still does not work.
(The API secret generated by Frappe UI works, but generated by programmatically as above does not)
Please help if I get wrong at some steps to generate API secret.
Generate API secret by code (Failed):
As you see, call the login API and the code generated the API Secret, and I use it to call other API, simply call the /get_logged_user it returns the failed results
Generate API secret by Admin UI (Sucess):
Generate by UI and use the secret, then use it to call /get_logged_user, it return successfully.
(1). The “/api/method/frappe.auth.get_logged_user” is just one of the ways I used to check if the auth token works or not
Maybe, instead of that API, I can call some other APIs to check the token, (e.g call API to Get library authors…)
(2). The main problem I show here is that the login API /library_management.customapi.login - it actually create, save and return a secret token, but I cannot use it to call any API as mention in (1).
I have a client app (reactjs) contains a login page, which will receive username/password to call this Login API, then returns a secret token.
=> So that I can use token to make further API to get/post data to Frappe as a back-end.
Using the Authentication header: “token <api_key>:<api_secret>”
So please help on this.
Or if you have any way for the Reactjs client app to login/get token/ then make further APIs call to frappe, please tell me.