mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
Extra fixes to NoTwitch Cache handling (#136)
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/136 Co-authored-by: Eroax <eroaxebusiness@duck.com> Co-committed-by: Eroax <eroaxebusiness@duck.com>
This commit is contained in:
parent
8896fed2f8
commit
82edd774a0
1 changed files with 11 additions and 11 deletions
|
@ -11,10 +11,13 @@ func _ready():
|
||||||
#confirmed.connect(connect_to_chat)
|
#confirmed.connect(connect_to_chat)
|
||||||
%Join_Chat.pressed.connect(connect_to_chat)
|
%Join_Chat.pressed.connect(connect_to_chat)
|
||||||
|
|
||||||
func authenticate_twitch():
|
func authenticate_twitch(skip_load = false):
|
||||||
|
|
||||||
# Temporary setup for loading credentials
|
# Temporary setup for loading credentials
|
||||||
var loaded_creds = Connections.load_credentials("twitch")
|
var loaded_creds = null
|
||||||
|
|
||||||
|
if !skip_load:
|
||||||
|
loaded_creds = Connections.load_credentials("twitch")
|
||||||
|
|
||||||
if loaded_creds != null:
|
if loaded_creds != null:
|
||||||
|
|
||||||
|
@ -26,25 +29,22 @@ func authenticate_twitch():
|
||||||
|
|
||||||
Connections.twitch.cache_user_data()
|
Connections.twitch.cache_user_data()
|
||||||
# Binds invalid auth to call No_Twitch.authenticate_with_twitch, handles if the cache of auth is invalid.
|
# Binds invalid auth to call No_Twitch.authenticate_with_twitch, handles if the cache of auth is invalid.
|
||||||
Connections.twitch.invalid_auth.connect(func():
|
Util.safe_connect(Connections.twitch.invalid_auth,authenticate_twitch.bind(true))
|
||||||
|
|
||||||
var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text)
|
|
||||||
OS.shell_open(url)
|
|
||||||
)
|
|
||||||
|
|
||||||
connect_to_chat()
|
connect_to_chat()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Handles first authentication/invalid cached authentication.
|
# Handles first authentication/invalid cached authentication.
|
||||||
Connections.twitch.token_received.connect(func(token):
|
Util.safe_connect(Connections.twitch.token_received, save_twitch_token)
|
||||||
|
|
||||||
Connections.save_credentials({"token" : token}, "twitch")
|
|
||||||
)
|
|
||||||
|
|
||||||
var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text)
|
var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text)
|
||||||
OS.shell_open(url)
|
OS.shell_open(url)
|
||||||
|
|
||||||
|
func save_twitch_token(token):
|
||||||
|
|
||||||
|
Connections.save_credentials({"token" : token}, "twitch")
|
||||||
|
|
||||||
|
|
||||||
func copy_auth_link():
|
func copy_auth_link():
|
||||||
var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text)
|
var url = Connections.twitch.authenticate_with_twitch(%Client_ID.text)
|
||||||
|
|
Loading…
Reference in a new issue