Authorize App
Authentication
Authorize App
Initiates OAuth 2.0 authorization for partner applications.
Setup
Create an OAuth app in Teleship Shipper Portal to get your clientId and clientSecret.
Usage
1. Start authorization:
const state = crypto.randomUUID();
sessionStorage.setItem('oauth_state', state);
window.location.href = `https://api.teleship.com/oauth/authorize?${new URLSearchParams({
clientId: 'your_client_id',
responseType: 'code',
redirectUri: 'https://yourapp.com/callback',
scope: 'read_accounts write_shipments',
state: state
})}`;
2. Handle callback:
const params = new URLSearchParams(window.location.search);
const code = params.get('code');
const accountClientId = params.get('account_client_id');
const accountClientSecret = params.get('account_client_secret');
const state = params.get('state');
// Validate state
if (state !== sessionStorage.getItem('oauth_state')) throw new Error('Invalid state');
3. Get access token:
const response = await fetch('https://api.teleship.com/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientId: accountClientId,
clientSecret: accountClientSecret
})
});
const { accessToken } = await response.json();
4. Make API calls:
fetch('https://api.teleship.com/api/shipments', {
headers: { 'Authorization': `Bearer ${accessToken}` }
});
Parameters
| Parameter | Required | Description |
|---|---|---|
clientId | Yes | OAuth app client ID |
responseType | Yes | Must be code |
redirectUri | Yes | Callback URL |
scope | Yes | Space-separated permissions |
state | Recommended | CSRF token |
Scopes
read_accountswrite_accountsread_shipmentswrite_shipments
GET
Authorize App
Query Parameters
OAuth client identifier
Example:
"app_xxxxxxxx"
OAuth response type (must be "code")
Example:
"code"
OAuth scopes being requested (space-separated)
Example:
"write_shipments write_orders"
OAuth redirect URI
Example:
"https://partner.com/oauth/callback"
OAuth state parameter for CSRF protection
Example:
"random-state-string"
Response
Redirect to UI for OAuth flow