Overview
Excerpt | ||
---|---|---|
| ||
Set up Salesforce User Creation API to allow a user to be created from the Salesforce a third party contact screen. |
This User Creation API is called with a payload (transmitted data) of the user information from the Salesforce a third party provider's contact screen. The web application will run validations and create the user after the validations are passed. An option in the payload is to specify whether a welcome email is to be sent to the user.
...
- The ClientID and ClientSecret (will be provided to you)
- The Token api endpoint: /api/token
- The api endpoint: /api/user
Prerequisites
- URL (will be provided to you)
- Username
- Password
- Sample Setup Request file (see sample at the end of this page)
- API testing app / browser add-on:
- Postman (Chrome) - https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en
- Poster (Firefox) - https://addons.mozilla.org/en-US/firefox/addon/poster/
Step-by-step guide
1. Get Authorisation Token
Before any API call is made, an authorisation token must be created.
...
- response.token_type: this is the authorisation type that is needed for the api calls (should be 'bearer' usually)
- response.access_token: this is the actual token
Make the API call
The token_type and access_token are needed to make the API call. The API endpoint requires use of the token type and token in the authorisation header.
...
NOTE - The response object should contain a response that allows you to see whether the call succeeded and whatever response information the call will return. All responses should contain "Success" and may contain "Message" (it should have the field but might have no content depending on the service). All other fields on the response object are endpoint specific.
Example
Below is an simple example of combining the above into a function that retrieves a token and caches it in local storage. It also retrieves the token if it is not cached or if the api endpoint call returns a 401 (not authorized) because the token is expires:
...