1) Create an integration:- The merchant creates an integration from Admin. Commerce generates a consumer key and a consumer secret.
2) Activate the integration:- The OAuth process begins when the merchant activates the integration. Magento sends the OAuth consumer key and secret, an OAuth verifier, and the store URL to the external application via HTTPS post to the page defined in the Callback Link field in Admin.
3) Process activation information:- The integrator must store the activation information received in step 2. These parameters will be used to ask for tokens.
4) Call the application’s login page:- Commerce calls the page defined in the Identity Link field in Admin.
5) Merchant logs in to the external application:- If the login is successful, the application returns to the location specified in the call. The login page is dismissed.
6) Ask for a request token:- The application uses the POST /oauth/token/request REST API to ask for a request token.
7) Send the request token:- Commerce returns a request token and request token secret
8) Ask for an access token:- The application uses the POST /oauth/token/access REST API to ask for an access token.
9) Commerce sends the access token:- If this request is successful, Magento returns an access token and access token secret.
10) The application can access Magento resources:- All requests sent to Commerce must use the full set of request parameters in Authorization header.
OAuth handshake details
The process of completing the OAuth handshake requires that you,
- Get a request token
- Get an access token
The response contains these fields:
1).Oauth_token:- The token to be used when requesting an access token.
2).Oauth_token_secret:- A secret value that establishes ownership of the token.
3). Session-based authentication
As a customer, you log in to the storefront with your customer credentials. As an admin, you log in to the Admin with your admin credentials. The web API framework uses your logged-in session information to verify your identity and authorize access to the requested resource.
Customers can access resources that are configured with anonymous or self permission in the webapi.xml configuration file. Admins can access resources that are assigned to their Admin profile.
For example, If a customer is logged in to the storefront and the JavaScript widget invokes the self API, details for the logged-in customer are fetched: