Skip to content

Commit

Permalink
=
Browse files Browse the repository at this point in the history
  • Loading branch information
arikaim-repository committed Oct 3, 2018
1 parent 9ca2c33 commit 6809be6
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
59 changes: 59 additions & 0 deletions OauthClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Arikaim
*
* @link http://www.arikaim.com
* @copyright Copyright (c) 2017-2018 Konstantin Atanasov <info@arikaim.com>
* @license http://www.arikaim.com/license.html
*
*/
namespace Arikaim\Modules\Oauth_Client;

use Arikaim\Core\Utils\Utils;
use Arikaim\Core\Module\Module;

class OauthClient extends Module
{
private $provider;

public function __construct()
{
$this->provider = null;
// module details
$this->setServiceName('oauth-client');
$this->setBootable(false);
}

public function __call($method, $args)
{
return Utils::call($this->provider,$method,$args);
}

public function create($provider_class_name = null, array $options = [], array $collaborators = [])
{
if ($provider_class_name == null || empty($provider_class_name) == true) {
$provider_class_name = "League\OAuth2\Client\Provider\GenericProvider";
}

$this->provider = new $provider_class_name($options,$collaborators);
return is_object($this->provider);
}

public function getProvider()
{
return $this->provider;
}

public function test()
{
try {
$test_options = ['urlAuthorize' => '*','urlAccessToken' => '*', '','urlResourceOwnerDetails' => '*'];
$result = $this->create(null,$test_options);
$this->provider = null;
} catch(\Exception $e) {
$this->error = $e->getMessage();
return false;
}
return $result;
}
}
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "arikaim/oauth-client-module",
"description": "Arikam Oauth Client Module",
"keywords": ["Module","OAuth","Arikaim Oauth client module"],
"type": "arikaim-module",
"license": "GPL-3.0-or-later",
"authors": [{
"name": "Konstantin Atanasov",
"email": "info@arikaim.com",
"homepage": "http://arikaim.com"
}],
"require": {
"php": ">=5.6.0",
"arikaim/installer": "*",
"league/oauth2-client": "^2.3"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"path": "oauth_client"
}
}
13 changes: 13 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "OAuth Client",
"version": "1.0",
"class": "OauthClient",
"description": "OAuth2 client.",
"requires": [
"league/oauth2-client"
],
"help": {
"url": "http://oauth2-client.thephpleague.com/"
},
"type": "module"
}

0 comments on commit 6809be6

Please # to comment.