Authintication
Authentication
You must know before using Emole Developer FrontEnd Api Endpoints that you need Two parameters sent it in header Section The Store APi Key and JWT Access Token,You Request Api Key From Emole Services Team Because You Can Show Any Store Data until The Vendor or Store owner Request it . **So After Store owner Bought your appliction mobile From Service Store Or Store owner send email To Service Team Email To request FrontEnd Api Premission our team Will Create Store Api Application And Send the api key and Access token **.
NOTE
The application API key must be stored on the client end because it needs to be sent in header of each request.Please save this key with you because you will need it while making further requests
CAUTION
You need a JWT access token to create request on all available public API methods except below mentioned methods:
/api/PublicGeneral/GetLocaleStringResources
/api/PublicGeneral/GetSettings
/api/PublicCustomer/GetGuestToken
For above mentioned methods you just need the application API key
Create a guest customer
To create a JWT access token, the first step is to create a request on /api/PublicCustomer/GetGuestToken method with the application API key in X-API-KEY header. On success, you will get an AccessToken in the response.
NOTE
You need to save this access token to further authorize a customer login and you can also continue to use guest customer access token to create requests on the other public methods unless disabled by the Emole Team.
In response to this method, you also get the RefreshToken and RefreshTokenExpiration which must be saved somewhere in order to request a new access token when the access token is expired.
var client = new RestClient("https://Test.com/api/PublicCustomer/GetGuestToken");
var request = new RestRequest(Method.GET);
request.AddHeader("X-API-KEY", "<API Key>");
var response = client.Execute(request);
INFO
The Response Will Contain Four items:
Customerid,AccessToken,RefreshToken,RefreshTokenExpiration
{
"CustomerId": -52828876,
"AccessToken": "occaecat est qui",
"RefreshToken": "Ut",
"RefreshTokenExpiration": "1957-07-09T07:32:43.022Z"
}
Login / Authentication
To login / authenticate a Store customer, you need to create a request on /api/PublicCustomer/Login method with the application API key in "X-API-KEY" header, guest access token in "Authorization", "Bearer " header. Along with request headers, you need to send the "Password" and the "UsernameOrEmail" as JSON string in the request body.
NOTE
On success, you will get the "CustomerId", a new "AccessToken", a new "RefreshToken" and a new "RefreshTokenExpiration" in the response which you need to save on your end to authenticate further requests on the server.
var client = new RestClient("https://test.com/api/PublicCustomer/Login");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<API Key>");
request.AddHeader("Authorization", "Bearer <Access Token>");
var body = @"{" + "\n" +
@" ""Password"": ""mollit proident in veniam minim""," + "\n" +
@" ""UsernameOrEmail"": ""velit nulla cupidatat elit""" + "\n" +
@"}";
request.AddParameter("text/plain", body, ParameterType.RequestBody);
var response = client.Execute(request);
Console.WriteLine(response.Content);
INFO
The Response will contain Five items:IsImpersonationAllowed,CustomerId,AccessToken,RefreshToken,RefreshTokenExpiration
{
"IsImpersonationAllowed": true,
"CustomerId": -65178875,
"AccessToken": "laborum",
"RefreshToken": "ut",
"RefreshTokenExpiration": "2018-11-13T03:06:10.020Z"
}
NOTE
You must differentiate between Quest Access token and Customer Access Token
The Quest Access Token It was done to calculate the number of visitors in the store Also To Handle Quest events Like add Product To card and payment event And So On.