Authentication, Webhooks setup - fnrfarid/excel-rma GitHub Wiki
Configure the rma-server connection to ERPNext
Make a post request using RESTer extension from Google Chrome Store then copy this json on the body and select json from the right corner menu. To get the variables, follow the below methods
{
"appURL" : "https://rma-server-url",
"warrantyAppURL" : "https://warranty-app-url",
"frontendClientId" : "XXXXXXXXXXXXXXXXXXX",
"backendClientId" : "XXXXXXXXXXXXXXXXXXX",
"serviceAccountUser" : "[email protected]",
"serviceAccountSecret" : "XXXXXXXXXXXXXXXXXXX",
"authServerURL" : "https://erp-site-url",
"serviceAccountApiKey" : "XXXXXXXXXXXXXXXXXXX",
"serviceAccountApiSecret" : "XXXXXXXXXXXXXXXXXXX"
}
To get the backendClientId: Login to erp.example.com as System Admin user, go to oAuth Client List to create a new Client.
- Name:
RMA Server
Skip Authorization
- URL+Redirected URIs:
https://rma-server-url/api/direct/callback
The app client ID is the backendClientId.
To get the serviceAccountUser:
We need to add a System Admin user named service_account
using [email protected]
as the email. Whatever the email address name is, that should be there on the json body as the serviceAccountUser
. The account password is the serviceAccountSecret.
Below the service account user details, under API Access, generate the key and save the pop up password. This should be the serviceAccountApiSecret
. The key is serviceAccountApiKey
.
To get the frontendClientID: Create another oAuth client.
- Name: RMA Client
- Skip Authorization
- Redirected URIs:
https://rma-server-url/callback https://rma-server-url/silent-refresh.html https://warranty-app-url/callback https://warranty-app-url/silent-refresh.html
- Default URI:
https://rma-server-url/callback
- Advance Settings: Grant Type> Implicit, Response Type> Token
The app client ID is the frontendClientID.
Once all the variables are collected, the RESTer Method should be POST and the URL should be https://rma-server-url/api/setup
Under the header section it should be Name> Content-Type, Value> application/json
Now, sending the request should be successful. To complete the connection, now we need to add a social login key. Go to Social Login Key list in ERPNext and create a key.
- Not enabled
- Login Provider: Frappe
- Base URL: https://erp-site-url
Now rma-server-url.com should allow to login via Frappe.
In case there's any mistake in MongoDB variables/RESTer variables
- We can't run the RESTer setup more than once. So if any mistake
- Delete the stopped Containers/Volumes/Associated Networks/Services of MongoDB
- Delete the Stack mongodb
- From server ssh terminal
docker system prune -f && docker volume prune -f
- This will clean things and reset passwords
- Redeploy the stack mongodb & rma-server
- Setup the RESTer connection again as everything was reset.
Setup Webhooks
Create another POST request using RESTer. Make Sure to logout from ERPNext/RMA-Server completely and login again from incognito to avoid errors.
- Method: POST
- URL: https://rma-server-url/api/settings/v1/setup_webhooks
- Header: Authorization
- Value: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Bearer token can be collected via this method:
- Login to https://rma-server-url,
- Open browser console by ctrl+shift+j then Application tab>Storage>IndexedDB>excel-rma>keyvaluepair
- the access token is the Bearer token variable.
Posting this will create all the webhooks and then we will have to setup the company and standard selling_price only from RMA-Server settings
.
After that logout and after 2 minutes login and setup the Debtor Account/Transfer Warehouse/Territory mapping etc.
If we face any error on login/redirect please check your client and API credentials and try to setup again.