diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index d33d4741d0..946d13c02a 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -37,13 +37,7 @@ namespace osu.Game.Online.API public Bindable LocalUser { get; } = new Bindable(createGuestUser()); - public string Token - { - get { return authentication.Token.Value?.ToString(); } - set { authentication.Token.Value = string.IsNullOrEmpty(value) ? null : OAuthToken.Parse(value); } - } - - protected bool HasLogin => Token != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password); + protected bool HasLogin => authentication.Token.Value != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password); private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource(); @@ -57,14 +51,14 @@ namespace osu.Game.Online.API log = Logger.GetLogger(LoggingTarget.Network); ProvidedUsername = config.Get(OsuSetting.Username); - Token = config.Get(OsuSetting.Token); + authentication.TokenString = config.Get(OsuSetting.Token); authentication.Token.ValueChanged += onTokenChanged; Task.Factory.StartNew(run, cancellationToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); } - private void onTokenChanged(OAuthToken token) => config.Set(OsuSetting.Token, config.Get(OsuSetting.SavePassword) ? Token : string.Empty); + private void onTokenChanged(OAuthToken token) => config.Set(OsuSetting.Token, config.Get(OsuSetting.SavePassword) ? authentication.TokenString : string.Empty); private readonly List components = new List(); diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index eec6f0648b..af01fc99a9 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -15,6 +15,12 @@ namespace osu.Game.Online.API public readonly Bindable Token = new Bindable(); + public string TokenString + { + get => Token.Value?.ToString(); + set => Token.Value = string.IsNullOrEmpty(value) ? null : OAuthToken.Parse(value); + } + internal OAuth(string clientId, string clientSecret, string endpoint) { Debug.Assert(clientId != null);