I found we need refresh token for renewing access token for REST API. But i couldn't find refresh token in response of my request. How can I get refresh token.Here is my code in PHP.
$postData = array(
'grant_type' => 'password',
'client_id' => 'my_client_id',
'client_secret' => 'my_client_secret',
'username' => 'my_admin_username',
'password' => 'my_admin_password+security token'
);
$token_url = 'https://cs57.salesforce.com/services/oauth2/token';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_HEADER => false,
CURLOPT_URL => $token_url,
CURLAUTH_ANY => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$response = json_decode($json_response,true);
print_r($response);
curl_close($curl);
And the response I get is
Array ( [access_token] => my token
[instance_url] => https://cs57.salesforce.com
[id] => https://test.salesforce.com/id/00D0k0000000Xu2EAE/0057F000000q8KFQAY
[token_type] => Bearer
[issued_at] => 1503288742327
[signature] => wt/b1QFLd8EJmIx6Max8rW2xmovdj3q/onMdKfExAqo=
)
As per the salesforce docs I should get refresh token also. But why I am not getting it. Or do I miss something here?
Update
It seems like, I asked a very dump question. I was following ' username-password authentication flow ' and the doc clearly says
" This OAuth authentication flow passes the user’s credentials back and forth. Use this authentication flow only when necessary. No refresh token is issued. "