Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/vendor/league/oauth2-client/src/Grant
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/league/oauth2-client/src/Grant')
-rw-r--r--vendor/league/oauth2-client/src/Grant/AuthorizationCode.php27
-rw-r--r--vendor/league/oauth2-client/src/Grant/ClientCredentials.php25
-rw-r--r--vendor/league/oauth2-client/src/Grant/GrantInterface.php12
-rw-r--r--vendor/league/oauth2-client/src/Grant/Password.php33
-rw-r--r--vendor/league/oauth2-client/src/Grant/RefreshToken.php29
5 files changed, 126 insertions, 0 deletions
diff --git a/vendor/league/oauth2-client/src/Grant/AuthorizationCode.php b/vendor/league/oauth2-client/src/Grant/AuthorizationCode.php
new file mode 100644
index 0000000..bda0965
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Grant/AuthorizationCode.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace League\OAuth2\Client\Grant;
+
+use League\OAuth2\Client\Token\AccessToken;
+
+class AuthorizationCode implements GrantInterface
+{
+ public function __toString()
+ {
+ return 'authorization_code';
+ }
+
+ public function prepRequestParams($defaultParams, $params)
+ {
+ if (! isset($params['code']) || empty($params['code'])) {
+ throw new \BadMethodCallException('Missing authorization code');
+ }
+
+ return array_merge($defaultParams, $params);
+ }
+
+ public function handleResponse($response = [])
+ {
+ return new AccessToken($response);
+ }
+}
diff --git a/vendor/league/oauth2-client/src/Grant/ClientCredentials.php b/vendor/league/oauth2-client/src/Grant/ClientCredentials.php
new file mode 100644
index 0000000..7a73a79
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Grant/ClientCredentials.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace League\OAuth2\Client\Grant;
+
+use League\OAuth2\Client\Token\AccessToken;
+
+class ClientCredentials implements GrantInterface
+{
+ public function __toString()
+ {
+ return 'client_credentials';
+ }
+
+ public function prepRequestParams($defaultParams, $params)
+ {
+ $params['grant_type'] = 'client_credentials';
+
+ return array_merge($defaultParams, $params);
+ }
+
+ public function handleResponse($response = array())
+ {
+ return new AccessToken($response);
+ }
+}
diff --git a/vendor/league/oauth2-client/src/Grant/GrantInterface.php b/vendor/league/oauth2-client/src/Grant/GrantInterface.php
new file mode 100644
index 0000000..a744ea9
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Grant/GrantInterface.php
@@ -0,0 +1,12 @@
+<?php
+
+namespace League\OAuth2\Client\Grant;
+
+interface GrantInterface
+{
+ public function __toString();
+
+ public function handleResponse($response = []);
+
+ public function prepRequestParams($defaultParams, $params);
+}
diff --git a/vendor/league/oauth2-client/src/Grant/Password.php b/vendor/league/oauth2-client/src/Grant/Password.php
new file mode 100644
index 0000000..b124b34
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Grant/Password.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace League\OAuth2\Client\Grant;
+
+use League\OAuth2\Client\Token\AccessToken;
+
+class Password implements GrantInterface
+{
+ public function __toString()
+ {
+ return 'password';
+ }
+
+ public function prepRequestParams($defaultParams, $params)
+ {
+ if (! isset($params['username']) || empty($params['username'])) {
+ throw new \BadMethodCallException('Missing username');
+ }
+
+ if (! isset($params['password']) || empty($params['password'])) {
+ throw new \BadMethodCallException('Missing password');
+ }
+
+ $params['grant_type'] = 'password';
+
+ return array_merge($defaultParams, $params);
+ }
+
+ public function handleResponse($response = array())
+ {
+ return new AccessToken($response);
+ }
+}
diff --git a/vendor/league/oauth2-client/src/Grant/RefreshToken.php b/vendor/league/oauth2-client/src/Grant/RefreshToken.php
new file mode 100644
index 0000000..86e7f6e
--- /dev/null
+++ b/vendor/league/oauth2-client/src/Grant/RefreshToken.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace League\OAuth2\Client\Grant;
+
+use League\OAuth2\Client\Token\AccessToken as AccessToken;
+
+class RefreshToken implements GrantInterface
+{
+ public function __toString()
+ {
+ return 'refresh_token';
+ }
+
+ public function prepRequestParams($defaultParams, $params)
+ {
+ if (! isset($params['refresh_token']) || empty($params['refresh_token'])) {
+ throw new \BadMethodCallException('Missing refresh_token');
+ }
+
+ $params['grant_type'] = 'refresh_token';
+
+ return array_merge($defaultParams, $params);
+ }
+
+ public function handleResponse($response = [])
+ {
+ return new AccessToken($response);
+ }
+}