Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/vendor/league/oauth2-client/src/Grant/Password.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/league/oauth2-client/src/Grant/Password.php')
-rw-r--r--vendor/league/oauth2-client/src/Grant/Password.php33
1 files changed, 33 insertions, 0 deletions
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);
+ }
+}