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(); + } +}