Skip to main content

Authorization

Create a TrackMake account

See How to sign up for TrackMage for instructions on creating new Account on TrackMage.

Create API Keys

To use TrackMage API, you'll need to generate an API Key and Secret which will be included with any calls made to the API. The Key and Secret are used to authenticate the API calls so that TrackMage updates the information within your specific account. To generate your API Key and Secret, follow the steps below:

  1. Go to Api Keys Settings
  2. Enter your App Name and App Url, press on Generate button
  3. Copy your Client Id and Secret

Obtain Authorization TOKEN

note

Ignore this step of you use TrackMage PHP SDK

note

Use generated "access_token" from response in the future requests.

curl --location --request GET 'https://api.trackmage.com/oauth/v2/token?grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET'

Example response:

{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1OTMwMDY1ODcsImV4cCI6MTU5MzAxMDE4Nywicm9sZXMiOltdLCJ1c2VybmFtZSI6ImhhcmJ1em5pYWsueWV2aGVuaWlAZ21haWwuY29tIn0.WyAtVsSq4z3T90-mVac7ReSHZ9ro3nBWKS_OqXoC2rkLxX4yiHGmgAZFrnojbJP0Qyq7nIliwRJO-32o24n4TVhoSmtyVNddVAHpHyTVhvS5MXK4huCvu1S30cCQBIPgSJFE82e7cu9-Sq50JmhvjTtW0_Ww0Jv1ofAm56q46k2RlvOus4SXvEBRJHP53FDSBjnGqTpogwy7FB6TZJfujxVBlA3VqPbj0L5bmchzg-dAvrZYrehEKsGTYPGXDveNg3ptAK1nQ56u-r_WgZ_uIpeBXNBnY9RRj_xZWFGYYIiMUhCueENDCFPya61BoxrjSu97EiP_vr7GYJ2FO-ObFbk5hKc-Pa6pI70ey6ai5VwQ0DgtSTJhvRBijphzNDP5ucAX0sn2xJYKHcgP91kAXWQTsVGZBD3e-cfN0S2K4VaG_nyLkQWn-DbN8SJa_-eoUFJ2R2OBOSHunRM1LQe9Ub2EQ9hh07JzR_T2XiTedJM8B02S6UoQ4sXuTdr0wEP5ANxTSYS6vWUatdm6A_K3inrhK82-qWyhldp2XrqC8a8XYThvTTBufxzUcTnjIEbrdgd-UPajSH7WFNl-mpRTE9I2vtYwFsKo1IHekPZu5hX5qs-ZSrRBqY4vGved2NS7gQ9TcZLzX6wSmEV7LpBMnSAQ1TXA_lGXBC7TSCsUI2A",
"expires_in": 3600,
"token_type": "bearer",
"scope": "user",
"user_id": "fe1dec62-490e-4f16-afb2-6f9dd303d930",
"user_email": "your@email.com"
}

OAuth Authentication flow

note

For integrating third-party application with TrackMage you'll need to generate client id and secret in TrackMage. Go to Api Keys Settings, specify App Name and App Url and click Generate.

  • The user clicks the Login with TrackMage button on any third-party application.
    curl --location --request GET 'https://api.trackmage.com/oauth/v2/auth?client_id=YOUR_CLIENT_ID&state=STATE&redirect_uri=https://example.com&response_type=code'
  • The application redirects the user to the TrackMage Login page, and the user enters the TrackMage credentials.
  • TrackMage asks the user whether he wants to Allow access to the third-party application.
  • User clicks the Allow button
  • TrackMage will redirect to the requested redirect url, e.g https://example.com?state=STATE&code=CODE
  • The third-party application obtains the access token
    curl --header "Content-Type: application/json" \
    --request POST \
    --data '{"grant_type": "authorization_code","code": "CODE", "redirect_uri": "https://example.com", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET"}' \
    https://api.trackmage.com/oauth/v2/auth

    Example response:

    {
    "access_token":"token",
    "expires_in":3600,
    "token_type":"bearer",
    "scope":null,
    "refresh_token":"token",
    "user_id":"e7508450-4aab-4c5f-b14d-d7440e6da3fd",
    "user_email":"test@example.com"
    }