Authorize App
curl --request GET \
--url https://api.teleship.com/oauth/authorizeimport requests
url = "https://api.teleship.com/oauth/authorize"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.teleship.com/oauth/authorize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.teleship.com/oauth/authorize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.teleship.com/oauth/authorize"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.teleship.com/oauth/authorize")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.teleship.com/oauth/authorize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}{
"success": false,
"error": {
"code": 401,
"message": "Invalid clientId or redirectUri"
}
}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
/
oauth
/
authorize
Authorize App
curl --request GET \
--url https://api.teleship.com/oauth/authorizeimport requests
url = "https://api.teleship.com/oauth/authorize"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.teleship.com/oauth/authorize', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.teleship.com/oauth/authorize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.teleship.com/oauth/authorize"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.teleship.com/oauth/authorize")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.teleship.com/oauth/authorize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"messages": [
{
"code": 123,
"level": "error",
"timestamp": "2024-01-01T00:00:00.00Z",
"message": "An error occurred",
"details": [
"Missing required field"
]
}
]
}{
"success": false,
"error": {
"code": 401,
"message": "Invalid clientId or redirectUri"
}
}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
Was this page helpful?