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
-
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
0
Answers
-
Yes, you can use CURL to get an access token. Use following command:
curl -v -X POST -H "Accept: application/json" -d "username=<<__MACHINE_ID__>>&password=<<__PASSWORD__>>&client_id=<<__APP_KEY__>>&grant_type=password&scope=trapi&takeExclusiveSignOnControl=true" https://api.refinitiv.com/auth/oauth2/v1/token
replace the parameters with your username/machineID, password and APP Key.
This quickstart guide shows how to create your app key.
0 -
Thank you both for your answers, you have solved my problem! It's puzzling not to simply have a public key and a private key like any other API, and you can't say that the documentation is very clear on that... One must guess that the client_id is the API key haha.
0 -
Yes, the public/private key pair support is enabled in the v2 authentication - which will also allow the JWT keypair for authorization.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 249 ETA
- 554 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 643 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 192 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛