parent
993add9398
commit
7ec9bf717f
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
use League\OAuth2\Client\Entity\User;
|
||||
|
||||
class Dropbox extends AbstractProvider
|
||||
{
|
||||
|
||||
public function urlAuthorize()
|
||||
{
|
||||
return 'https://www.dropbox.com/1/oauth2/authorize';
|
||||
}
|
||||
|
||||
public function urlAccessToken()
|
||||
{
|
||||
return 'https://api.dropbox.com/1/oauth2/token';
|
||||
}
|
||||
|
||||
public function urlUserDetails(\League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
return 'https://api.dropbox.com/1/account/info?access_token='.$token;
|
||||
}
|
||||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
$user = new User;
|
||||
|
||||
$user->uid = $response->uid;
|
||||
$user->name = $response->display_name;
|
||||
$user->email = $response->email;
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function getAuthorizationUrl($options = array())
|
||||
{
|
||||
return parent::getAuthorizationUrl(array_merge([
|
||||
'approval_prompt' => []
|
||||
], $options));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace League\OAuth2\Client\Test\Provider;
|
||||
|
||||
use Mockery as m;
|
||||
|
||||
class DropboxTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $provider;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->provider = new \League\OAuth2\Client\Provider\Dropbox([
|
||||
'clientId' => 'mock_client_id',
|
||||
'clientSecret' => 'mock_secret',
|
||||
'redirectUri' => 'none',
|
||||
]);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testAuthorizationUrl()
|
||||
{
|
||||
$url = $this->provider->getAuthorizationUrl([
|
||||
'approval_prompt' => []
|
||||
]);
|
||||
$uri = parse_url($url);
|
||||
parse_str($uri['query'], $query);
|
||||
|
||||
$this->assertArrayHasKey('client_id', $query);
|
||||
$this->assertArrayHasKey('redirect_uri', $query);
|
||||
$this->assertArrayHasKey('state', $query);
|
||||
$this->assertArrayHasKey('scope', $query);
|
||||
$this->assertArrayHasKey('response_type', $query);
|
||||
$this->assertArrayNotHasKey('approval_prompt', $query);
|
||||
$this->assertNotNull($this->provider->state);
|
||||
}
|
||||
|
||||
public function testUrlAccessToken()
|
||||
{
|
||||
$url = $this->provider->urlAccessToken();
|
||||
$uri = parse_url($url);
|
||||
|
||||
$this->assertEquals('/1/oauth2/token', $uri['path']);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue