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
1
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.
1 -
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
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛