Refactored all providers
This commit is contained in:
parent
60a2019715
commit
3303dd1f4b
|
@ -63,29 +63,25 @@ class Amazon extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded;charset=UTF-8'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded;charset=UTF-8'];
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://api.amazon.com/auth/o2/token',
|
'https://api.amazon.com/auth/o2/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID ,
|
'client_id' => $this->appID ,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'redirect_uri' => $this->callback ,
|
'redirect_uri' => $this->callback ,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,32 +58,28 @@ class Apple extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://appleid.apple.com/auth/token',
|
'https://appleid.apple.com/auth/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->getAppSecret(),
|
'client_secret' => $this->getAppSecret(),
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// $this->claims = (isset($accessToken['id_token'])) ? \explode('.', $accessToken['id_token']) : [0 => '', 1 => ''];
|
$this->claims = (isset($result['id_token'])) ? \explode('.', $result['id_token']) : [0 => '', 1 => ''];
|
||||||
// $this->claims = (isset($this->claims[1])) ? \json_decode(\base64_decode($this->claims[1]), true) : [];
|
$this->claims = (isset($this->claims[1])) ? \json_decode(\base64_decode($this->claims[1]), true) : [];
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,30 +47,26 @@ class Bitbucket extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// // Required as per Bitbucket Spec.
|
// Required as per Bitbucket Spec.
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
//
|
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://bitbucket.org/site/oauth2/access_token',
|
'https://bitbucket.org/site/oauth2/access_token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,29 +58,24 @@ class Bitly extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $response = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->resourceEndpoint . 'oauth/access_token',
|
$this->resourceEndpoint . 'oauth/access_token',
|
||||||
// ["Content-Type: application/x-www-form-urlencoded"],
|
["Content-Type: application/x-www-form-urlencoded"],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// "client_id" => $this->appID,
|
"client_id" => $this->appID,
|
||||||
// "client_secret" => $this->appSecret,
|
"client_secret" => $this->appSecret,
|
||||||
// "code" => $code,
|
"code" => $code,
|
||||||
// "redirect_uri" => $this->callback,
|
"redirect_uri" => $this->callback,
|
||||||
// "state" => \json_encode($this->state)
|
"state" => \json_encode($this->state)
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $result = null;
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if ($response) {
|
|
||||||
// \parse_str($response, $result);
|
|
||||||
// return $result['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,30 +63,26 @@ class Box extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $header = "Content-Type: application/x-www-form-urlencoded";
|
$header = "Content-Type: application/x-www-form-urlencoded";
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint . 'token',
|
$this->endpoint . 'token',
|
||||||
// [$header],
|
[$header],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// "client_id" => $this->appID,
|
"client_id" => $this->appID,
|
||||||
// "client_secret" => $this->appSecret,
|
"client_secret" => $this->appSecret,
|
||||||
// "code" => $code,
|
"code" => $code,
|
||||||
// "grant_type" => "authorization_code",
|
"grant_type" => "authorization_code",
|
||||||
// "scope" => \implode(',', $this->getScopes()),
|
"scope" => \implode(',', $this->getScopes()),
|
||||||
// "redirect_uri" => $this->callback
|
"redirect_uri" => $this->callback
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (array_key_exists('access_token', $accessToken)) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,29 +59,25 @@ class Discord extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint . '/oauth2/token',
|
$this->endpoint . '/oauth2/token',
|
||||||
// ['Content-Type: application/x-www-form-urlencoded'],
|
['Content-Type: application/x-www-form-urlencoded'],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'scope' => \implode(' ', $this->getScopes())
|
'scope' => \implode(' ', $this->getScopes())
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,29 +48,25 @@ class Dropbox extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://api.dropboxapi.com/oauth2/token',
|
'https://api.dropboxapi.com/oauth2/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,25 +51,21 @@ class Facebook extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'GET',
|
'GET',
|
||||||
// 'https://graph.facebook.com/'.$this->version.'/oauth/access_token?'.\http_build_query([
|
'https://graph.facebook.com/'.$this->version.'/oauth/access_token?'.\http_build_query([
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'code' => $code
|
'code' => $code
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,29 +46,23 @@ class Github extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://github.com/login/oauth/access_token',
|
'https://github.com/login/oauth/access_token',
|
||||||
// [],
|
[],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'code' => $code
|
'code' => $code
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $output = [];
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// \parse_str($accessToken, $output);
|
|
||||||
//
|
|
||||||
// if (isset($output['access_token'])) {
|
|
||||||
// return $output['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,26 +50,22 @@ class Gitlab extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://gitlab.com/oauth/token?'.\http_build_query([
|
'https://gitlab.com/oauth/token?'.\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,27 +59,23 @@ class Google extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://oauth2.googleapis.com/token?'.\http_build_query([
|
'https://oauth2.googleapis.com/token?'.\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'scope' => null,
|
'scope' => null,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,28 +61,24 @@ class Linkedin extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://www.linkedin.com/oauth/v2/accessToken',
|
'https://www.linkedin.com/oauth/v2/accessToken',
|
||||||
// ['Content-Type: application/x-www-form-urlencoded'],
|
['Content-Type: application/x-www-form-urlencoded'],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,31 +53,27 @@ class Microsoft extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
//
|
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://login.microsoftonline.com/'.$this->getTenantId().'/oauth2/v2.0/token',
|
'https://login.microsoftonline.com/'.$this->getTenantId().'/oauth2/v2.0/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->getClientSecret(),
|
'client_secret' => $this->getClientSecret(),
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'scope' => \implode(' ', $this->getScopes()),
|
'scope' => \implode(' ', $this->getScopes()),
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,26 +51,22 @@ class Mock extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'GET',
|
'GET',
|
||||||
// 'http://localhost/'.$this->version.'/mock/tests/general/oauth2/token?'.
|
'http://localhost/'.$this->version.'/mock/tests/general/oauth2/token?'.
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'code' => $code
|
'code' => $code
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true); //
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,30 +55,26 @@ class Notion extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = [
|
$headers = [
|
||||||
// "Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
"Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
||||||
// ];
|
];
|
||||||
//
|
|
||||||
// $response = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint . '/oauth/token',
|
$this->endpoint . '/oauth/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'code' => $code
|
'code' => $code
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $response = \json_decode($response, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($response['access_token'])) {
|
|
||||||
// return $response['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,27 +78,21 @@ class Paypal extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->resourceEndpoint[$this->environment] . 'oauth2/token',
|
$this->resourceEndpoint[$this->environment] . 'oauth2/token',
|
||||||
// ['Authorization: Basic ' . \base64_encode($this->appID . ':' . $this->appSecret)],
|
['Authorization: Basic ' . \base64_encode($this->appID . ':' . $this->appSecret)],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
//
|
$result = \json_decode($result, true);
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,30 +63,27 @@ class Salesforce extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = [
|
$headers = [
|
||||||
// "Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
"Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
||||||
// "Content-Type: application/x-www-form-urlencoded",
|
"Content-Type: application/x-www-form-urlencoded",
|
||||||
// ];
|
];
|
||||||
//
|
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://login.salesforce.com/services/oauth2/token',
|
'https://login.salesforce.com/services/oauth2/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'redirect_uri' => $this->callback ,
|
'redirect_uri' => $this->callback ,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
|
||||||
//
|
$result = \json_decode($result, true);
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,26 +50,22 @@ class Slack extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// // https://api.slack.com/docs/oauth#step_3_-_exchanging_a_verification_code_for_an_access_token
|
// https://api.slack.com/docs/oauth#step_3_-_exchanging_a_verification_code_for_an_access_token
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'GET',
|
'GET',
|
||||||
// 'https://slack.com/api/oauth.access?'.\http_build_query([
|
'https://slack.com/api/oauth.access?'.\http_build_query([
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'redirect_uri' => $this->callback
|
'redirect_uri' => $this->callback
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true); //
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,25 +62,21 @@ class Spotify extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $header = "Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret);
|
$header = "Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret);
|
||||||
// $result = \json_decode($this->request(
|
$result = \json_decode($this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint . 'api/token',
|
$this->endpoint . 'api/token',
|
||||||
// [$header],
|
[$header],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// "code" => $code,
|
"code" => $code,
|
||||||
// "grant_type" => "authorization_code",
|
"grant_type" => "authorization_code",
|
||||||
// "redirect_uri" => $this->callback
|
"redirect_uri" => $this->callback
|
||||||
// ])
|
])
|
||||||
// ), true);
|
), true);
|
||||||
//
|
|
||||||
// if (isset($result['access_token'])) {
|
|
||||||
// return $result['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,29 +61,25 @@ class Stripe extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $response = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://connect.stripe.com/oauth/token',
|
'https://connect.stripe.com/oauth/token',
|
||||||
// [],
|
[],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'grant_type' => $this->grantType['authorize'],
|
'grant_type' => $this->grantType['authorize'],
|
||||||
// 'code' => $code
|
'code' => $code
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $response = \json_decode($response, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($response['stripe_user_id'])) {
|
if (isset($result['stripe_user_id'])) {
|
||||||
// $this->stripeAccountId = $response['stripe_user_id'];
|
$this->stripeAccountId = $result['stripe_user_id'];
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (isset($response['access_token'])) {
|
|
||||||
// return $response['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,22 +73,21 @@ class Tradeshift extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $response = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint[$this->environment] . 'auth/token',
|
$this->endpoint[$this->environment] . 'auth/token',
|
||||||
// ['Authorization: Basic ' . \base64_encode($this->appID . ':' . $this->appSecret)],
|
['Authorization: Basic ' . \base64_encode($this->appID . ':' . $this->appSecret)],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($response, true);
|
$result = \json_decode($result, true);
|
||||||
// return $accessToken['access_token'] ?? '';
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,35 +61,31 @@ class Vk extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded;charset=UTF-8'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded;charset=UTF-8'];
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://oauth.vk.com/access_token?',
|
'https://oauth.vk.com/access_token?',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'redirect_uri' => $this->callback
|
'redirect_uri' => $this->callback
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['email'])) {
|
if (isset($result['email'])) {
|
||||||
// $this->user['email'] = $accessToken['email'];
|
$this->user['email'] = $result['email'];
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (isset($accessToken['user_id'])) {
|
if (isset($result['user_id'])) {
|
||||||
// $this->user['user_id'] = $accessToken['user_id'];
|
$this->user['user_id'] = $result['user_id'];
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,28 +50,24 @@ class WordPress extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://public-api.wordpress.com/oauth2/token',
|
'https://public-api.wordpress.com/oauth2/token',
|
||||||
// [],
|
[],
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'redirect_uri' => $this->callback,
|
'redirect_uri' => $this->callback,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'grant_type' => 'authorization_code',
|
'grant_type' => 'authorization_code',
|
||||||
// 'code' => $code
|
'code' => $code
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,29 +74,25 @@ class Yahoo extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $header = [
|
$header = [
|
||||||
// "Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
"Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
||||||
// "Content-Type: application/x-www-form-urlencoded",
|
"Content-Type: application/x-www-form-urlencoded",
|
||||||
// ];
|
];
|
||||||
//
|
|
||||||
// $result = \json_decode($this->request(
|
$result = \json_decode($this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint . 'get_token',
|
$this->endpoint . 'get_token',
|
||||||
// $header,
|
$header,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// "code" => $code,
|
"code" => $code,
|
||||||
// "grant_type" => "authorization_code",
|
"grant_type" => "authorization_code",
|
||||||
// "redirect_uri" => $this->callback
|
"redirect_uri" => $this->callback
|
||||||
// ])
|
])
|
||||||
// ), true);
|
), true);
|
||||||
//
|
|
||||||
// if (isset($result['access_token'])) {
|
|
||||||
// return $result['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,29 +48,25 @@ class Yammer extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = ['Content-Type: application/x-www-form-urlencoded'];
|
$headers = ['Content-Type: application/x-www-form-urlencoded'];
|
||||||
//
|
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// $this->endpoint . 'access_token?',
|
$this->endpoint . 'access_token?',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'client_id' => $this->appID,
|
'client_id' => $this->appID,
|
||||||
// 'client_secret' => $this->appSecret,
|
'client_secret' => $this->appSecret,
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
$result = \json_decode($result, true);
|
||||||
//
|
|
||||||
// if (isset($accessToken['access_token']['token'])) {
|
|
||||||
// return $accessToken['access_token']['token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,29 +60,26 @@ class Yandex extends OAuth2
|
||||||
*/
|
*/
|
||||||
public function getTokens(string $code): array
|
public function getTokens(string $code): array
|
||||||
{
|
{
|
||||||
// $headers = [
|
$headers = [
|
||||||
// "Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
"Authorization: Basic " . \base64_encode($this->appID . ":" . $this->appSecret),
|
||||||
// "Content-Type: application/x-www-form-urlencoded",
|
"Content-Type: application/x-www-form-urlencoded",
|
||||||
// ];
|
];
|
||||||
//
|
|
||||||
// $accessToken = $this->request(
|
$result = $this->request(
|
||||||
// 'POST',
|
'POST',
|
||||||
// 'https://oauth.yandex.com/token',
|
'https://oauth.yandex.com/token',
|
||||||
// $headers,
|
$headers,
|
||||||
// \http_build_query([
|
\http_build_query([
|
||||||
// 'code' => $code,
|
'code' => $code,
|
||||||
// 'grant_type' => 'authorization_code'
|
'grant_type' => 'authorization_code'
|
||||||
// ])
|
])
|
||||||
// );
|
);
|
||||||
// $accessToken = \json_decode($accessToken, true);
|
|
||||||
//
|
$result = \json_decode($result, true);
|
||||||
// if (isset($accessToken['access_token'])) {
|
|
||||||
// return $accessToken['access_token'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'access' => '',
|
'access' => $result['access_token'],
|
||||||
'refresh' => ''
|
'refresh' => $result['refresh_token']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue