From 556a62b34b44f9c89de6d5a0d70a5f6f63b18e05 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 6 Apr 2018 11:36:29 +0200 Subject: [PATCH] adding app/library/OAuth/Adapter classes (interface and League adapter) --- .../OAuth/Adapter/AdapterInterface.php | 43 +++++++++++ app/library/OAuth/Adapter/League.php | 73 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 app/library/OAuth/Adapter/AdapterInterface.php create mode 100644 app/library/OAuth/Adapter/League.php diff --git a/app/library/OAuth/Adapter/AdapterInterface.php b/app/library/OAuth/Adapter/AdapterInterface.php new file mode 100644 index 0000000..676a6f2 --- /dev/null +++ b/app/library/OAuth/Adapter/AdapterInterface.php @@ -0,0 +1,43 @@ +_provider = $provider; + } + + /** + * {@inheritDoc} + */ + public function getProviderName() + { + return (new \ReflectionClass($this->_provider))->getShortName(); + } + + /** + * {@inheritDoc} + */ + public function getAuthorizationUrl() + { + return $this->_provider->getAuthorizationUrl(); + } + + /** + * {@inheritDoc} + */ + public function fetchAccessToken($code) + { + $this->_accessToken = $this->_provider->getAccessToken('authorization_code', [ + 'code' => $code + ]); + } + + /** + * {@inheritDoc} + */ + public function getResourceData() + { + $resource = $this->_provider->getResourceOwner($this->_accessToken); + return $resource->toArray(); + } +}