Skip to content

Refreshing an access token - PHP #282

Answered by ralfonso4
ralfonso4 asked this question in Q&A
Discussion options

You must be logged in to vote

Think i fixed it: Using the refresh_token from step3 and not from step4!!!

public function refreshAccessToken(string $refreshToken)
{
$tesla = new Tesla();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pastebin.com/raw/pS7Z6yyP');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$api = explode(PHP_EOL,$result);
$id=explode('=',$api[0]);
$secret=explode('=',$api[1]);
$tesla->setClientId(trim($id[1]));
$tesla->setClientSecret(trim($secret[1]));

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $this->tokenUrlNew);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  curl_setopt($ch, CURLOPT_POS…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ralfonso4
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants