Skip to content

Commit 32f9e1a

Browse files
committed
:octocat: +Tidal provider
1 parent 10ffc9e commit 32f9e1a

File tree

7 files changed

+155
-0
lines changed

7 files changed

+155
-0
lines changed

.config/.env_example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ STRIPE_SECRET=
230230
STRIPE_CALLBACK_URL=
231231
#STRIPE_TESTUSER=
232232

233+
# https://developer.tidal.com/dashboard/
234+
TIDAL_KEY=
235+
TIDAL_SECRET=
236+
TIDAL_CALLBACK_URL=
237+
#TIDAL_TESTUSER=
238+
233239
# https://www.tumblr.com/oauth/apps
234240
TUMBLR_KEY=
235241
TUMBLR_SECRET=

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Note: check the [releases](https://github.com/chillerlan/php-oauth/releases) for
143143
| [Spotify](https://developer.spotify.com/documentation/web-api/) | [link](https://developer.spotify.com/dashboard) | [link](https://www.spotify.com/account/apps/) | 2 |||||| |
144144
| [Steam](https://developer.valvesoftware.com/wiki/Steam_Web_API) | [link](https://steamcommunity.com/dev/apikey) | | - || | | | | |
145145
| [Stripe](https://stripe.com/docs/api) | [link](https://dashboard.stripe.com/apikeys) | [link](https://dashboard.stripe.com/account/applications) | 2 ||| | |||
146+
| [Tidal](https://developer.tidal.com/documentation) | [link](https://developer.tidal.com/dashboard) | [link](https://account.tidal.com/third-party-apps) | 2 |||||| |
146147
| [Tumblr](https://www.tumblr.com/docs/en/api/v2) | [link](https://www.tumblr.com/oauth/apps) | [link](https://www.tumblr.com/settings/apps) | 1 || | | | | |
147148
| [Tumblr2](https://www.tumblr.com/docs/en/api/v2) | [link](https://www.tumblr.com/oauth/apps) | [link](https://www.tumblr.com/settings/apps) | 2 ||| ||| |
148149
| [Twitch](https://dev.twitch.tv/docs/api/reference/) | [link](https://dev.twitch.tv/console/apps/create) | [link](https://www.twitch.tv/settings/connections) | 2 ||| ||||

docs/Basics/Overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fully [PSR-7](https://www.php-fig.org/psr/psr-7/)/[PSR-17](https://www.php-fig.o
7878
| [Spotify](https://developer.spotify.com/documentation/web-api/) | [link](https://developer.spotify.com/dashboard) | [link](https://www.spotify.com/account/apps/) | 2 |||||| |
7979
| [Steam](https://developer.valvesoftware.com/wiki/Steam_Web_API) | [link](https://steamcommunity.com/dev/apikey) | | - || | | | | |
8080
| [Stripe](https://stripe.com/docs/api) | [link](https://dashboard.stripe.com/apikeys) | [link](https://dashboard.stripe.com/account/applications) | 2 ||| | |||
81+
| [Tidal](https://developer.tidal.com/documentation) | [link](https://developer.tidal.com/dashboard) | [link](https://account.tidal.com/third-party-apps) | 2 |||||| |
8182
| [Tumblr](https://www.tumblr.com/docs/en/api/v2) | [link](https://www.tumblr.com/oauth/apps) | [link](https://www.tumblr.com/settings/apps) | 1 || | | | | |
8283
| [Tumblr2](https://www.tumblr.com/docs/en/api/v2) | [link](https://www.tumblr.com/oauth/apps) | [link](https://www.tumblr.com/settings/apps) | 2 ||| ||| |
8384
| [Twitch](https://dev.twitch.tv/docs/api/reference/) | [link](https://dev.twitch.tv/console/apps/create) | [link](https://www.twitch.tv/settings/connections) | 2 ||| ||||

examples/get-token/Tidal.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* @link https://developer.tidal.com/documentation/api-sdk/api-sdk-authorization
4+
*
5+
* @created 04.08.2025
6+
* @author Smiley <smiley@chillerlan.net>
7+
* @copyright 2025 Smiley
8+
* @license MIT
9+
*/
10+
declare(strict_types=1);
11+
12+
use chillerlan\OAuth\Providers\Tidal;
13+
14+
require_once __DIR__.'/../provider-example-common.php';
15+
16+
/** @var \OAuthExampleProviderFactory $factory */
17+
$provider = $factory->getProvider(Tidal::class);
18+
19+
require_once __DIR__.'/_flow-oauth2.php';
20+
21+
exit;

src/Providers/Tidal.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Class Tidal
4+
*
5+
* @created 04.08.2025
6+
* @author smiley <smiley@chillerlan.net>
7+
* @copyright 2025 smiley
8+
* @license MIT
9+
*
10+
* @noinspection PhpUnused
11+
*/
12+
declare(strict_types=1);
13+
14+
namespace chillerlan\OAuth\Providers;
15+
16+
use chillerlan\OAuth\Core\{
17+
AuthenticatedUser, ClientCredentials, ClientCredentialsTrait,
18+
OAuth21Provider, TokenRefresh, UserInfo
19+
};
20+
21+
/**
22+
* Tidal OAuth2 (OAuth 2.1)
23+
*
24+
* @link https://developer.tidal.com/documentation/api-sdk/api-sdk-authorization
25+
*/
26+
class Tidal extends OAuth21Provider implements ClientCredentials, TokenRefresh, UserInfo{
27+
use ClientCredentialsTrait;
28+
29+
public const IDENTIFIER = 'TIDAL';
30+
31+
public const SCOPE_COLLECTION_READ = 'collection.read';
32+
public const SCOPE_COLLECTION_WRITE = 'collection.write';
33+
public const SCOPE_ENTITLEMENTS_READ = 'entitlements.read';
34+
public const SCOPE_PLAYBACK = 'playback';
35+
public const SCOPE_PLAYLISTS_READ = 'playlists.read';
36+
public const SCOPE_PLAYLISTS_WRITE = 'playlists.write';
37+
public const SCOPE_RECOMMENDATIONS_READ = 'recommendations.read';
38+
public const SCOPE_SEARCH_READ = 'search.read';
39+
public const SCOPE_SEARCH_WRITE = 'search.write';
40+
public const SCOPE_USER_READ = 'user.read';
41+
42+
public const DEFAULT_SCOPES = [
43+
self::SCOPE_COLLECTION_READ,
44+
self::SCOPE_COLLECTION_WRITE,
45+
self::SCOPE_PLAYLISTS_READ,
46+
self::SCOPE_PLAYLISTS_WRITE,
47+
self::SCOPE_RECOMMENDATIONS_READ,
48+
self::SCOPE_USER_READ,
49+
];
50+
51+
public const HEADERS_API = [
52+
'Accept' => 'application/vnd.api+json',
53+
];
54+
55+
public const USES_BASIC_AUTH_IN_ACCESS_TOKEN_REQUEST = true;
56+
57+
protected string $authorizationURL = 'https://login.tidal.com/authorize';
58+
protected string $accessTokenURL = 'https://auth.tidal.com/v1/oauth2/token';
59+
protected string $apiURL = 'https://openapi.tidal.com';
60+
protected string|null $userRevokeURL = 'https://account.tidal.com/third-party-apps';
61+
protected string|null $apiDocs = 'https://developer.tidal.com/documentation';
62+
protected string|null $applicationURL = 'https://developer.tidal.com/dashboard';
63+
64+
65+
public function me():AuthenticatedUser{
66+
$json = $this->getMeResponseData('/v2/users/me');
67+
68+
$userdata = [
69+
'data' => $json,
70+
'handle' => $json['data']['attributes']['username'],
71+
'email' => $json['data']['attributes']['email'],
72+
'id' => $json['data']['id'],
73+
];
74+
75+
return new AuthenticatedUser($userdata);
76+
}
77+
78+
}

tests/Providers/Live/TidalAPITest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Class TidalAPITest
4+
*
5+
* @created 04.08.2025
6+
* @author smiley <smiley@chillerlan.net>
7+
* @copyright 2025 smiley
8+
* @license MIT
9+
*/
10+
declare(strict_types=1);
11+
12+
namespace chillerlan\OAuthTest\Providers\Live;
13+
14+
use chillerlan\OAuth\Providers\Tidal;
15+
use chillerlan\OAuthTest\Attributes\Provider;
16+
use PHPUnit\Framework\Attributes\Group;
17+
18+
/**
19+
* @property \chillerlan\OAuth\Providers\Tidal $provider
20+
*/
21+
#[Group('providerLiveTest')]
22+
#[Provider(Tidal::class)]
23+
class TidalAPITest extends OAuth2ProviderLiveTestAbstract{
24+
25+
}

tests/Providers/Unit/TidalTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Class TidalTest
4+
*
5+
* @created 04.08.2025
6+
* @author smiley <smiley@chillerlan.net>
7+
* @copyright 2025 smiley
8+
* @license MIT
9+
*/
10+
declare(strict_types=1);
11+
12+
namespace chillerlan\OAuthTest\Providers\Unit;
13+
14+
use chillerlan\OAuth\Providers\Tidal;
15+
use chillerlan\OAuthTest\Attributes\Provider;
16+
17+
/**
18+
* @property \chillerlan\OAuth\Providers\Tidal $provider
19+
*/
20+
#[Provider(Tidal::class)]
21+
class TidalTest extends OAuth2ProviderUnitTestAbstract{
22+
23+
}

0 commit comments

Comments
 (0)