API LIBRARY
Collapse Sidebar Menu
Expand Drawer

Authentication in WebApi

To authenticate with the Web API protocol, you will need the username and password for your account.

Execute the query demonstrated below, and store the value of the token. On subsequent queries, provide the HTTP header:

Authorization: Bearer [TOKEN VALUE]

Examples

Code Example

curl -X POST \
--output "token.json" \
--basic -u $username:$password \
-H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" \
-k -d "grant_type=client_credentials&scope=api&client_id=$username" \
'https://api-prod.corelogic.com/trestle/oidc/connect/token'

Result

{
    "access_token": "token",
    "expires_in": 28800,
    "token_type": "Bearer"
}

Code Example

<?php

$request = new HttpRequest();
$request->setUrl('https://api-prod.corelogic.com/trestle/oidc/connect/token');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
    'cache-control' => 'no-cache'
));

$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
  'client_id' => '$username',
  'client_secret' => '$password',
  'grant_type' => 'client_credentials',
  'scope' => 'api'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Result

{
    "access_token": "token",
    "expires_in": 28800,
    "token_type": "Bearer"
}