What do I need to call a Swift API?
You will need a Token URL, an API Scope and Grant Type that are listed below. You will also need a Client ID, Client Secret that need to be provided by a Swift+ representative
Getting a Token
To call Swift+ APIs, you'll need a JSON Web Token (JWT) from ONEOK - Magellan. This token includes the necessary information to access and authorize your usage. To get a token, you'll need four pieces of information:
• The Token URL
• Your Client Id and Client Secret
• An API Scope
• The Grant Type
The rest of this section will describe how to use these four pieces in a token request.
Token URLs
In order to get a token for an API call, you’ll first need to make a POST request to our token provider.
The URL for the provider is as follows: https://login.microsoftonline.com/d8088b60-8534-41bd-a682- 1ad5ee71069a/oauth2/v2.0/token
The URL alone is not enough to get a token. Read on to understand what headers and body parameters you’ll also need to provide.
Request Headers
The only header you need to include is a content-type header.
Please use the following:
• Content-Type: application/x-www-form-urlencoded
Request Body
There are four parameters you’ll need to include in the body of the request to get a valid token.
Client Id
• client_id={ClientId}
Replace {ClientId} with your company-specific client id. This id should have been provided to you by ONEOK - Magellan. If not, please contact your Swift+ representative.
Client Secret
• client_secret={ClientSecret}
Replace {ClientSecret} with your company-specific client secret provided by ONEOK - Magellan. If you haven't received it, please contact your Swift+ representative for assistance.
Scope
• scope={ApiScope}
Each APIs requires a unique token. The scope parameter is necessary to obtain a token for the specific API you intend to call. The currently available scopes are:
MOCK
api://swift-mock-inventory-api/.default
api://swift-mock-loading-api/.default
api://swift-mock-shipping-api/.default
api://swift-mock-billing-api/.default
api://swift-mock-locations-api/.default
OPEN
api://swift-open-inventory-api/.default
api://swift-open-loading-api/.default
api://swift-open-shipping-api/.default
api://swift-open-billing-api/.default
api://swift-open-locations-api/.default
Replace {ApiScope} with the scope for the desired API.
Grant Type
• grant_type=client_credentials
No changes are needed here. Including this indicates that the Client Credentials flow is being used in your token request.