mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-06 12:24:03 +01:00
Start implementing oauth process
Signed-off-by: Laurent ARNAL <laurent@clae.net>
This commit is contained in:
parent
677965775f
commit
1bb278c3f6
@ -26,14 +26,16 @@ import org.openhab.core.thing.ThingTypeUID;
|
|||||||
public class TidalBindingConstants {
|
public class TidalBindingConstants {
|
||||||
|
|
||||||
// List of Tidal services related urls, information
|
// List of Tidal services related urls, information
|
||||||
public static final String TIDAL_ACCOUNT_URL = "https://accounts.tidal.com";
|
public static final String TIDAL_LOGIN_URL = "https://login.tidal.com";
|
||||||
public static final String TIDAL_AUTHORIZE_URL = TIDAL_ACCOUNT_URL + "/authorize";
|
public static final String TIDAL_AUTH_URL = "https://auth.tidal.com";
|
||||||
public static final String TIDAL_API_TOKEN_URL = TIDAL_ACCOUNT_URL + "/api/token";
|
public static final String TIDAL_AUTHORIZE_URL = TIDAL_LOGIN_URL + "/authorize";
|
||||||
|
public static final String TIDAL_API_TOKEN_URL = TIDAL_AUTH_URL + "/v1/oauth2/token";
|
||||||
/**
|
/**
|
||||||
* Tidal scopes needed by this binding to work.
|
* Tidal scopes needed by this binding to work.
|
||||||
*/
|
*/
|
||||||
public static final String TIDAL_SCOPES = Stream.of("user-read-playback-state", "user-modify-playback-state",
|
public static final String TIDAL_SCOPES = Stream.of("playlists.read", "entitlements.read", "collection.read",
|
||||||
"playlist-read-private", "playlist-read-collaborative").collect(Collectors.joining(" "));
|
"playlists.write", "collection.write", "user.read", "recommendations.read", "playback")
|
||||||
|
.collect(Collectors.joining(" "));
|
||||||
public static final String TIDAL_API_URL = "https://api.tidal.com/v1/me";
|
public static final String TIDAL_API_URL = "https://api.tidal.com/v1/me";
|
||||||
public static final String TIDAL_API_PLAYER_URL = TIDAL_API_URL + "/player";
|
public static final String TIDAL_API_PLAYER_URL = TIDAL_API_URL + "/player";
|
||||||
|
|
||||||
|
@ -82,8 +82,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
* @author Hilbrand Bouwkamp - Just a lot of refactoring
|
* @author Hilbrand Bouwkamp - Just a lot of refactoring
|
||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TidalBridgeHandler extends BaseBridgeHandler
|
public class TidalBridgeHandler extends BaseBridgeHandler implements TidalAccountHandler, AccessTokenRefreshListener {
|
||||||
implements TidalAccountHandler, AccessTokenRefreshListener {
|
|
||||||
|
|
||||||
private static final CurrentlyPlayingContext EMPTY_CURRENTLY_PLAYING_CONTEXT = new CurrentlyPlayingContext();
|
private static final CurrentlyPlayingContext EMPTY_CURRENTLY_PLAYING_CONTEXT = new CurrentlyPlayingContext();
|
||||||
private static final Album EMPTY_ALBUM = new Album();
|
private static final Album EMPTY_ALBUM = new Album();
|
||||||
@ -256,7 +255,14 @@ public class TidalBridgeHandler extends BaseBridgeHandler
|
|||||||
if (oAuthService == null) {
|
if (oAuthService == null) {
|
||||||
throw new OAuthException("OAuth service is not initialized");
|
throw new OAuthException("OAuth service is not initialized");
|
||||||
}
|
}
|
||||||
return oAuthService.getAuthorizationUrl(redirectUri, null, thing.getUID().getAsString());
|
oAuthService.addExtraAuthField("test", "toto");
|
||||||
|
String oAuthorizationUrl = oAuthService.getAuthorizationUrl(redirectUri, null,
|
||||||
|
thing.getUID().getAsString());
|
||||||
|
|
||||||
|
String cChallenge = "E9Melhoa2OwvFrEMTJguCHaoeKt8URWbuGJSstw-cM";
|
||||||
|
oAuthorizationUrl = oAuthorizationUrl + "&code_challenge_method=S256";
|
||||||
|
oAuthorizationUrl = oAuthorizationUrl + "&code_challenge=" + cChallenge;
|
||||||
|
return oAuthorizationUrl;
|
||||||
} catch (final OAuthException e) {
|
} catch (final OAuthException e) {
|
||||||
logger.debug("Error constructing AuthorizationUrl: ", e);
|
logger.debug("Error constructing AuthorizationUrl: ", e);
|
||||||
return "";
|
return "";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="block${player.authorized}" id="${player.id}">
|
<div class="block${player.authorized}" id="${player.id}">
|
||||||
Connect to Tidal: <i>${player.name}${player.user}</i>
|
Connect to Tidal: <i>${player.name}${player.user}</i>
|
||||||
<p><div class="button"><a href=${player.authorize}>Authorize Player</a></div></p>
|
<p><div class="button"><a href="${player.authorize}">Authorize Player</a></div></p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user