Connect 3rd Party Server to Frappe (Machine-to-Machine) using Bearer Token

I want to integrate 3rd party app server to access erpnext resources via rest api. For every request hit from that server I want to authenticate it using Oauth to get bearer token

I have setup Frappe as Social Login Key, then add OAuth Client for 3rd party server. Grant type is Authorization Code.

The problem is GET /api/method/frappe.integrations.oauth2.authorize uses browser uri callback then make another api call to get bearer token

How to get authorization code as json result, so that 3rd party app server can use authorization_code in json result then make get_token request to get bearer token…

now user has to open browser for redirect_url to get authorization_code

I think authorization code type is more suitable for 3rd party apps running on browser.

How about server-to-server integration? Basically this 3rd party server needs access to post data to Erpnext resource…so basically I want to grant this server using Oauth, give back bearer access_token, where Frappe is the provider…for every hit request.

I see client_credentials is not implemented yet in Frappe. Any thoughts please? Thanks

Just figured out we can use refresh_token to regenerate access_token. We can use this for server-to-server. call authorize endpoint to get authorized_code. End user allow it, redirect url to get authorized_code, then make get_token call to get token along with refresh_token

1 Like