From 5dcabaf5cff101c9b71b55d3bca0d4340514fc5c Mon Sep 17 00:00:00 2001 From: derrod Date: Sun, 3 Apr 2022 17:48:02 +0200 Subject: [PATCH] UI: Make OAuth base URL configurable --- UI/CMakeLists.txt | 6 ++++++ UI/auth-oauth.cpp | 4 +++- UI/auth-restream.cpp | 5 ++--- UI/auth-twitch.cpp | 4 ++-- UI/ui-config.h.in | 2 ++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index f4fd39e71..33a8b9627 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -26,6 +26,12 @@ if(TARGET obs-browser obs-browser-panels INTERFACE ${CMAKE_SOURCE_DIR}/plugins/obs-browser/panel) endif() +set(OAUTH_BASE_URL + "https://auth.obsproject.com/" + CACHE STRING "Default OAuth base URL") + +mark_as_advanced(OAUTH_BASE_URL) + if(NOT DEFINED TWITCH_CLIENTID OR "${TWITCH_CLIENTID}" STREQUAL "" OR NOT DEFINED TWITCH_HASH diff --git a/UI/auth-oauth.cpp b/UI/auth-oauth.cpp index 39da15b84..c19be67bd 100644 --- a/UI/auth-oauth.cpp +++ b/UI/auth-oauth.cpp @@ -14,6 +14,8 @@ #include +#include "ui-config.h" + using namespace json11; #ifdef BROWSER_AVAILABLE @@ -93,7 +95,7 @@ void OAuthLogin::urlChanged(const QString &url) if (code_idx == -1) return; - if (url.left(22) != "https://obsproject.com") + if (!url.startsWith(OAUTH_BASE_URL)) return; code_idx += (int)uri.size(); diff --git a/UI/auth-restream.cpp b/UI/auth-restream.cpp index 1d5d5d244..f242deb9e 100644 --- a/UI/auth-restream.cpp +++ b/UI/auth-restream.cpp @@ -19,9 +19,8 @@ using namespace json11; /* ------------------------------------------------------------------------- */ -#define RESTREAM_AUTH_URL \ - "https://obsproject.com/app-auth/restream?action=redirect" -#define RESTREAM_TOKEN_URL "https://obsproject.com/app-auth/restream-token" +#define RESTREAM_AUTH_URL OAUTH_BASE_URL "v1/restream/redirect" +#define RESTREAM_TOKEN_URL OAUTH_BASE_URL "v1/restream/token" #define RESTREAM_STREAMKEY_URL "https://api.restream.io/v2/user/streamKey" #define RESTREAM_SCOPE_VERSION 1 diff --git a/UI/auth-twitch.cpp b/UI/auth-twitch.cpp index d9f5bbdab..af942e9e2 100644 --- a/UI/auth-twitch.cpp +++ b/UI/auth-twitch.cpp @@ -22,8 +22,8 @@ using namespace json11; /* ------------------------------------------------------------------------- */ -#define TWITCH_AUTH_URL "https://obsproject.com/app-auth/twitch?action=redirect" -#define TWITCH_TOKEN_URL "https://obsproject.com/app-auth/twitch-token" +#define TWITCH_AUTH_URL OAUTH_BASE_URL "v1/twitch/redirect" +#define TWITCH_TOKEN_URL OAUTH_BASE_URL "v1/twitch/token" #define TWITCH_SCOPE_VERSION 1 diff --git a/UI/ui-config.h.in b/UI/ui-config.h.in index cf84248fd..53d57caa6 100644 --- a/UI/ui-config.h.in +++ b/UI/ui-config.h.in @@ -18,6 +18,8 @@ #cmakedefine USE_XDG +#define OAUTH_BASE_URL "@OAUTH_BASE_URL@" + #define TWITCH_ENABLED @TWITCH_ENABLED@ #define TWITCH_CLIENTID "@TWITCH_CLIENTID@" #define TWITCH_HASH 0x@TWITCH_HASH@