oauth2-client/src/Grant/AuthorizationCode.php

28 lines
617 B
PHP
Raw Normal View History

2013-02-26 15:33:00 +04:00
<?php
2013-05-28 14:00:24 +04:00
namespace League\OAuth2\Client\Grant;
use League\OAuth2\Client\Token\AccessToken;
2013-02-26 15:33:00 +04:00
class AuthorizationCode implements GrantInterface
2013-11-18 06:45:28 +04:00
{
2013-02-26 15:33:00 +04:00
public function __toString()
{
return 'authorization_code';
}
public function prepRequestParams($defaultParams, $params)
{
2014-05-03 14:55:30 +04:00
if (! isset($params['code']) || empty($params['code'])) {
2013-02-26 15:33:00 +04:00
throw new \BadMethodCallException('Missing authorization code');
}
return array_merge($defaultParams, $params);
}
2014-11-09 00:30:40 +03:00
public function handleResponse($response = [])
2013-02-26 15:33:00 +04:00
{
return new AccessToken($response);
}
2013-11-18 06:45:28 +04:00
}