mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
feat: getAccessToken Done
This commit is contained in:
parent
17590846a1
commit
681acbdffa
1 changed files with 10 additions and 12 deletions
|
|
@ -39,7 +39,7 @@ class Stackoverflow extends OAuth
|
||||||
'&state='.urlencode(json_encode($this->state));
|
'&state='.urlencode(json_encode($this->state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $code
|
* @param string $code
|
||||||
*
|
*
|
||||||
|
|
@ -47,22 +47,20 @@ class Stackoverflow extends OAuth
|
||||||
*/
|
*/
|
||||||
public function getAccessToken(string $code): string
|
public function getAccessToken(string $code): string
|
||||||
{
|
{
|
||||||
var_dump($code);
|
|
||||||
exit();
|
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
|
||||||
|
|
||||||
$accessToken = $this->request(
|
$accessToken = $this->request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://www.googleapis.com/oauth2/'.$this->version.'/token?'.
|
'https://stackoverflow.com/oauth/access_token/json',
|
||||||
'code='.urlencode($code).
|
$headers,
|
||||||
'&client_id='.urlencode($this->appID).
|
'code=' . urlencode($code) .
|
||||||
'&client_secret='.urlencode($this->appSecret).
|
'&client_id=' . urlencode($this->appID) .
|
||||||
'&redirect_uri='.urlencode($this->callback).
|
'&client_secret=' . urlencode($this->appSecret).
|
||||||
'&scope='.
|
'&redirect_uri='.urlencode($this->callback)
|
||||||
'&grant_type=authorization_code'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$accessToken = json_decode($accessToken, true);
|
$accessToken = json_decode($accessToken, true);
|
||||||
|
|
||||||
if (isset($accessToken['access_token'])) {
|
if (isset($accessToken['access_token'])) {
|
||||||
return $accessToken['access_token'];
|
return $accessToken['access_token'];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue