[Iplant-api-dev] token retrieval not working
Duvick, Jonathan P [GDCBS]
jduvick at iastate.edu
Wed Jan 7 09:17:13 MST 2015
I'm refactoring an Atmosphere VM for Agave, accomplished via Web forms generated by PHP, and I've succeeded in getting step 1 (client app registration/retrieve keys) accomplished. Step 2 (retrieve auth token and refresh token) is not working. It always returns http_code '400' in response to my curl request, suggesting malformed syntax.
Can anyone spot a problem in this code? My client app ('xGDBvm') is successfully registered (it shows up on https://agave.iplantc.org/store/site/pages/applications.jag)<https://agave.iplantc.org/store/site/pages/applications.jag> and I am successfully passing the associated consumer key/_secret string values in the curl request after retrieving them from a MySQL table. In the snippet below, $base_url is https://agave.iplantc.org.<https://agave.iplantc.org>
$ch = curl_init();
$url="${base_url}/token";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$credentials = "${consumer_key}:${consumer_secret}";
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-type: application/x-www-form-urlencoded'));
$post_params = array(
'grant_type'=>'password',
'username'=>$username,
'password'=>$password,
'scope'=>'PRODUCTION'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$response = curl_exec($ch);
$resultStatus = curl_getinfo($ch);
Jon Duvick
PlantGDB Manager
http://www.plantgdb.org/
Department of Genetics, Development and Cell Biology
2258 Molecular Biology Building
Iowa State University
Ames IA 50011
(515) 294-2360
(515) 294-6755 FAX
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iplantcollaborative.org/pipermail/iplant-api-dev/attachments/20150107/f1e6524e/attachment.html
More information about the Iplant-api-dev
mailing list