I am using a PHP integration with UBER API. I am having trouble with the OAuth flow. I get {"error": "invalid_grant"}
after trying to exchange an access code for an access token.
It was working well, but today it just stopped working. Debugging it, I see that Uber is providing access code in this format: IPjvWABDxk00000BxQQwJksP2I50qD#_
and I believe that the "#_
" at the end is causing me problems, as php $_GET
won't be able to read the full string (from IP
.. to ...#_
).
My code:
$uber_access_code = $_GET["code"];
$fields_string = '';
$fields = array(
'client_secret' => $uber_client_secret,
'client_id' => $uber_client_id,
'grant_type' => 'authorization_code',
'code' => $uber_access_code,
'redirect_uri' => $uber_redirect_uri,
);
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, "https://login.uber.com/oauth/v2/token");
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
Question: How can I read the full string parameter from PHP? $_GET trims "#_
" on my end, but I need the whole string.