// Returns a Tuple<userId, refreshToken> public static async Task <Tuple <string, string> > Login(Credentials credentials, Uri serverUrl) { var result = await MakeAuthRequestAsync(serverUrl, credentials.ToJson(), TimeSpan.FromSeconds(30)).ConfigureAwait(continueOnCapturedContext: false); var refresh_token = result["refresh_token"]; return(Tuple.Create((string)refresh_token["token_data"]["identity"], (string)refresh_token["token"])); }
public static async Task <User> LoginAsync(Credentials credentials, Uri serverUrl, LoginMode loginMode = LoginMode.UseExistingAccount) { if (credentials.IdentityProvider == Credentials.Providers.AccessToken) { var identity = (string)credentials.UserInfo[Credentials.Keys.Identity]; var isAdmin = (bool)credentials.UserInfo[Credentials.Keys.IsAdmin]; return(new User(SyncUserHandle.GetSyncUser(identity, credentials.Token, serverUrl?.AbsoluteUri, isAdmin))); } var result = await MakeAuthRequestAsync(serverUrl, credentials.ToJson(), TimeSpan.FromSeconds(30)).ConfigureAwait(continueOnCapturedContext: false); var refresh_token = result["refresh_token"]; return(new User(SyncUserHandle.GetSyncUser(refresh_token["token_data"]["identity"], refresh_token["token"], serverUrl.AbsoluteUri, false))); }