- Company’s Name: This is presented to the user during the OAuth flow when they connect their Shippo account to your platform
- Callback URL: The URL vendors are redirected to after they connect their Shippo account. This is your site URL followed by /shippo-oauth-redirect/
- Contact Email: Your email address
- Brief description of use case
Additional Details: section.
The OAuth connection flow
The following process applies for setting up a Shippo account for a user on your platform:- Step 1: Starting on your site, the users clicks a link or button that takes them to the Shippo OAuth flow. The user is prompted to login or register for a Shippo account and, if missing, enter billing information (e.g. credit card). Finally, the user grants your platform permission to access their Shippo account.
- Step 2: The user is then redirected back to your site, passing along either an authorization code or an error in case the user chose not to complete the OAuth flow.
- Step 3: You need to make a request to our OAuth token endpoint to fetch the user’s account ID and store it on your platform.
Step 1: Link to the Shippo OAuth flow
To initiate the OAuth flow, your platform needs to link to the following URL:response_type: “code”client_id: your unique partner ID (provided to you by Shippo)scope: ”*” (currently this is the only supported scope, allowing you full Shippo API access)state: a random string generated by your application, which you’ll verify later to prevent CSRF attacksutm_source: an ID for your application (provided to you by Shippo)
- Register a new Shippo account or login with an existing account.
- If missing, enter billing information (e.g. credit card) to enable their Shippo account for production label purchase and other paid Shippo features.
- Grant your platform permission to access their account.
Step 2: Redirect to your site
After the user completed the OAuth flow, they are redirected back to your site’sredirect_uri:
code: the authorization codestate: the random string you passed in step 1
state value to ensure it matches the one you started with in step 1. You can typically store the state value in a cookie or session, and compare it when the user comes back. This ensures your redirection endpoint isn’t able to be tricked into attempting to exchange arbitrary authorization codes.
If the authorization was denied by the user, they’ll still be redirected back to your site, but the URL includes an error instead of the authorization code:
Step 3: Fetching user credentials via token exchange
In the last step you use thecode from step 2 to fetch your user’s access token, which you need for API authentication:
client_id: your unique partner IDclient_secret: your Shippo OAuth API secret key (different from your Shippo API key)code: the authorization code provided in step 2grant_type: “authorization_code”
token_type: “bearer”scope: ”*”access_token: the access you use to make API calls on behalf of your user. It never expires.
access_token. It remains valid forever and you don’t need to implement a refresh mechanism.
If the token exchange request fails, you get back an error response:
Authentication
Once you have completed the OAuth flow for a user, you can make Shippo API requests on behalf of this user by authenticating via the normalAuthorization header.
Important NoteUse the Bearer
access_token you generated in Step 3 to authenticate in the Authorization header.The format is "Authorization: Bearer oauth.612BUDkTaTuJP3ll5-VkebURX", where oauth.612BUDkTaTuJP3ll5-VkebURX is the generated access_token.This will not work if you use the format "Authorization: ShippoToken".Versioning
Since your users might independently upgrade the API version of their Shippo account, it’s important that you explicitly set your API version in all of your API calls that you make on behalf of your users. You can set the API version in the header like this:OAuth Redirects
After your user has logged into their Shippo account, they are redirected back to your site. By default, you defined this redirect by the URL (Callback URL) you sent to our support team when setting up your OAuth. During development and testing, it may be useful for you to be able to change your callback URL. For example, you may want to redirect to a development server while you build your integration. Depending on your development strategy, you might add redirects for development, test, production, or even localhost. To control which redirect URL you use, include the query parameter&redirect_uri followed by the URL you want to redirect your user to after they have logged into their Shippo account.
If you do not specify a &redirect_uri, your default redirect URL is used.
noteYou must send all callback URLs you want to use to our partner support team in advance. You can do this when you first setup your OAuth or can you can make a request afterwards. The feature described in this guide will not function until your callback URLs have been configured by our team. You can add as many as you need but you must specify which one is your default.
https://mysite.com/. It’s important to note the closing / on your URI is required.