-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTumblr2.php
59 lines (48 loc) · 1.72 KB
/
Tumblr2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Class Tumblr2
*
* @created 30.07.2023
* @author smiley <smiley@chillerlan.net>
* @copyright 2023 smiley
* @license MIT
*/
declare(strict_types=1);
namespace chillerlan\OAuth\Providers;
use chillerlan\OAuth\Core\{
AuthenticatedUser, ClientCredentials, ClientCredentialsTrait, CSRFToken, OAuth2Provider, TokenRefresh, UserInfo,
};
use function sprintf;
/**
* Tumblr OAuth2
*
* @link https://www.tumblr.com/docs/en/api/v2#oauth2-authorization
*/
class Tumblr2 extends OAuth2Provider implements CSRFToken, TokenRefresh, ClientCredentials, UserInfo{
use ClientCredentialsTrait;
public const IDENTIFIER = 'TUMBLR2';
public const SCOPE_BASIC = 'basic';
public const SCOPE_WRITE = 'write';
public const SCOPE_OFFLINE_ACCESS = 'offline_access';
public const DEFAULT_SCOPES = [
self::SCOPE_BASIC,
self::SCOPE_WRITE,
self::SCOPE_OFFLINE_ACCESS,
];
protected string $authorizationURL = 'https://www.tumblr.com/oauth2/authorize';
protected string $accessTokenURL = 'https://api.tumblr.com/v2/oauth2/token';
protected string $apiURL = 'https://api.tumblr.com';
protected string|null $userRevokeURL = 'https://www.tumblr.com/settings/apps';
protected string|null $apiDocs = 'https://www.tumblr.com/docs/en/api/v2';
protected string|null $applicationURL = 'https://www.tumblr.com/oauth/apps';
/** @codeCoverageIgnore */
public function me():AuthenticatedUser{
$json = $this->getMeResponseData('/v2/user/info');
$userdata = [
'data' => $json,
'handle' => $json['response']['user']['name'],
'url' => sprintf('https://www.tumblr.com/%s', $json['response']['user']['name']),
];
return new AuthenticatedUser($userdata);
}
}