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. Substitute the values into the following examples.

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://trestle.corelogic.com/oidc/connect/token'

Result

{
    "access_token": "token",
    "expires_in": 3600,
    "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": 3600,
    "token_type": "Bearer"
}