Curl request with PHP - Where can I find parameters ?

I'm trying to make a curl request with PHP to the endpoint https://api.refinitiv.com/auth/oauth2/v1/token in order to get an access_token, which I can then use to access the other endpoints that Refinitiv provides. However, I'm encountering some difficulties. From what I understand, the following fields are mandatory:

  • grant_type ("password")
  • username (my email address)
  • password (my password)

On the other hand, I have no idea where I can find the following information:

  • scope
  • client_id
  • client_secret

Having combed through the rather thin associated documentation, the client_id and client_secret would be associated with my application created via the AppKey Generator, but if the field names matched what I can see there, that would be too easy. So, do you know where I can find the "scope" parameter, and what do "client_id" and "client_secret" correspond to in the AppKey Generator?

Thank you very much for your help!

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @edouard.chene

    The PHP code for Authentication V1 should look like this:

    <?php
    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => 'https://api.refinitiv.com/auth/oauth2/v1/token',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS => 'username=<username>&password=<password>&grant_type=password&scope=trapi&takeExclusiveSignOnControl=true&client_id=<client id>',
      CURLOPT_HTTPHEADER => array(
        'Content-Type: application/x-www-form-urlencoded'
      ),
    ));
    $response = curl_exec($curl);
    curl_close($curl);
    echo $response;

    This code is generated by Postman. You can download the RDP Postman collection from here and refer to this article: Generate code for a REST API call using Postman in just a few clicks regarding how to generate code from Postman

Answers