Authorize (Get user API key)

This endpoint authenticates an Xtracta user and returns the API key assigned to that user. Authenticate with either a current login_token, or the user's emailaddress and password.

Warning

Credential security: Call this endpoint only from a trusted backend. Treat passwords, login tokens, and returned API keys as secrets, and never expose them in browser-delivered code.

POST Parameters

ParameterRequiredValueDescription
login_token{string}A current login token. Supply this by itself, or use emailaddress and password instead.
emailaddress{email}The user's email address. Required when login_token is not supplied.
password{string}The user's password. Required with emailaddress when login_token is not supplied.

Code Examples

The cURL, PHP, Python, Node.js, and C# examples call Xtracta from a trusted server. The React example calls an application-defined backend proxy so the API key is never exposed in browser code.

Warning

Send authentication values only to your own backend. Do not call the Xtracta endpoint directly from browser code.

curl --request POST 'https://api-app.xtracta.com/v1/user/authorize' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'login_token=<LOGIN_TOKEN>'

Sample Request

Using a login token:

POST https://api-app.xtracta.com/v1/user/authorize HTTP/1.1
Content-Type: application/x-www-form-urlencoded

login_token=<LOGIN_TOKEN>

Using an email address and password:

POST https://api-app.xtracta.com/v1/user/authorize HTTP/1.1
Content-Type: application/x-www-form-urlencoded

emailaddress=user@example.com&password=<PASSWORD>

Sample Response

<?xml version="1.0" encoding="UTF-8"?>
<user_response>
    <status>200</status>
    <message>The request has been successfully processed</message>
    <user_id>12345</user_id>
    <user_name>John Doe</user_name>
    <api_key>example-api-key</api_key>
</user_response>

Schema Definition

Response Elements

ElementDescription
<status>The response status code.
<message>Human-readable information about the operation.
<user_id>The authenticated user's ID.
<user_name>The authenticated user's name.
<api_key>The API key assigned to the authenticated user.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="user_response">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="status" type="xs:positiveInteger"/>
        <xs:element name="message" type="xs:string"/>
        <xs:element name="user_id" type="xs:positiveInteger" minOccurs="0"/>
        <xs:element name="user_name" type="xs:string" minOccurs="0"/>
        <xs:element name="api_key" type="xs:string" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Error Responses

For JSON and XML responses generated by this endpoint, the response is wrapped in user_response and includes the HTTP status code and a message.

StatusMessageDescription
401Invalid authentication informationSupply a valid login token, or a valid email address and password.
401Login token is expiredRequest a new login token and retry.
500multiple application for user(...) foundThe user has an ambiguous API-application mapping. Contact support.
500Internal server error occurred. Please try again later or contact support@xtracta.comRetry and contact support with the request parameters and timestamp if it persists.
Information Circle

This endpoint performs user authentication, so its expected credential failures are listed above. IP-access-control and rate-limit failures may still be returned before authorization completes.