EasyParcel (Singapore) Help Centre

Login Sign Up
Welcome
Login

How do I sign in to the Open API with OAuth 2.0?

Quick Summary

EasyParcel uses OAuth 2.0 with the Authorization Code flow. You send the user to the login page, get a code back, then swap the code for an access token. You send that token in every API request.

We'll Cover:

  • The steps
  • Use the token
  • When the token expires
  • Good to know

The steps

  1. Send the user to https://api.easyparcel.com/oauth/login with your client_id, your redirect_uri and, if you want, a state value (a random text that protects against forged requests).
  2. The user logs in to EasyParcel, chooses the account to link (Sandbox or Live) and clicks Allow Access.
  3. EasyParcel sends the user back to your redirect URI with a code (and your state).
  4. Your server sends a POST to https://api.easyparcel.com/oauth/token with grant_type = authorization_code, the redirect_uri and the code. Add the header Authorization: Basic followed by your client ID and client secret joined with a colon and encoded in Base64.
  5. The reply has your access_token (token type Bearer), expires_in (36000 seconds, which is 10 hours) and a refresh_token.

The sign-in flow in short.

Step 2: the user logs in to EasyParcel.

The user chooses the account to link.

The user clicks Allow Access.


Use the token

Send the access token in the header of every API call:

Authorization: Bearer YOUR_ACCESS_TOKEN

When the token expires

The refresh token lasts much longer than the access token (about a year). When the access token ends, send a POST to the same token address with grant_type = refresh_token and your refresh_token, using the same Basic header. Do not ask the user to sign in again unless the refresh token has also ended.


Good to know


Still need help?
Our team is happy to help. ? Live Chat  |  ✉️ Contact Us

E
EasyParcel is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.