mirror of
https://github.com/anikeen-com/id.git
synced 2026-03-13 13:46:13 +00:00
@@ -51,6 +51,11 @@ class AnikeenId
|
||||
*/
|
||||
private static string $baseUrl = 'https://id.anikeen.com/api/';
|
||||
|
||||
/**
|
||||
* The staging base URL for Anikeen ID API.
|
||||
*/
|
||||
private static string $stagingBaseUrl = 'https://staging.id.anikeen.com/api/';
|
||||
|
||||
/**
|
||||
* The key for the access token.
|
||||
*/
|
||||
@@ -105,6 +110,9 @@ class AnikeenId
|
||||
if ($redirectUri = config('services.anikeen.redirect')) {
|
||||
$this->setRedirectUri($redirectUri);
|
||||
}
|
||||
if (config('services.anikeen.mode') === 'staging') {
|
||||
self::setBaseUrl(self::$stagingBaseUrl);
|
||||
}
|
||||
if ($baseUrl = config('services.anikeen.base_url')) {
|
||||
self::setBaseUrl($baseUrl);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Anikeen\Id\Socialite;
|
||||
|
||||
use Anikeen\Id\Enums\Scope;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laravel\Socialite\Two\ProviderInterface;
|
||||
use SocialiteProviders\Manager\OAuth2\AbstractProvider;
|
||||
@@ -26,13 +27,25 @@ class Provider extends AbstractProvider implements ProviderInterface
|
||||
*/
|
||||
protected $scopeSeparator = ' ';
|
||||
|
||||
/**
|
||||
* Get the base URL for the API.
|
||||
*/
|
||||
protected function getBaseUrl(): string
|
||||
{
|
||||
$mode = $this->config['mode'] ?? 'production';
|
||||
|
||||
return $mode === 'staging'
|
||||
? 'https://staging.id.anikeen.com'
|
||||
: 'https://id.anikeen.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getAuthUrl($state): string
|
||||
{
|
||||
return $this->buildAuthUrlFromBase(
|
||||
'https://id.anikeen.com/oauth/authorize', $state
|
||||
$this->getBaseUrl() . '/oauth/authorize', $state
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,7 +54,7 @@ class Provider extends AbstractProvider implements ProviderInterface
|
||||
*/
|
||||
protected function getTokenUrl(): string
|
||||
{
|
||||
return 'https://id.anikeen.com/oauth/token';
|
||||
return $this->getBaseUrl() . '/oauth/token';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +65,7 @@ class Provider extends AbstractProvider implements ProviderInterface
|
||||
protected function getUserByToken($token)
|
||||
{
|
||||
$response = $this->getHttpClient()->get(
|
||||
'https://id.anikeen.com/api/v1/user', [
|
||||
$this->getBaseUrl() . '/api/v1/user', [
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
|
||||
Reference in New Issue
Block a user