public async Task TestUserLogin() { await ResetTestAsync(); MAS.ConfigFileName = "msso_config.json"; MAS.RegistrationKind = RegistrationKind.Client; await MAS.StartAsync(); Assert.IsTrue(MASDevice.Current?.IsRegistered == true); await MASUser.LoginAsync("zoljo01", "IdentityMine"); Assert.IsTrue(MASUser.Current?.IsLoggedIn == true); }
private async void LoginButton_Click(object sender, RoutedEventArgs e) { App.IsBusy = true; ErrorText.Text = string.Empty; try { await MASUser.LoginAsync(UsernameText.Text, PasswordText.Password); // We have logged in successfully at this point, dismiss and continue ((App)App.Current).NavigateToWelcome(); } catch (Exception exp) { ErrorText.Text = exp.ToString(); } App.IsBusy = false; }
public static async Task <UserInfoResponseData> GetUserInfoAsync(Configuration config, MASDevice device, MASUser user) { var url = config.GetEndpointPath(config.OAuth.ProjectedEndpoints.UserInfo); var accessTokenHeaderValue = await user.GetAccessHeaderValueAsync(); var headers = new Dictionary <string, string> { { HttpHeaders.Authorization, accessTokenHeaderValue }, { "mag-identifier", device.MagId }, { HttpHeaders.Accept, HttpContentTypes.Json } }; return(await HttpRequestFactory.RequestAsync <UserInfoResponseData>(new HttpRequestInfo() { Url = url, Method = HttpMethod.GET, Headers = headers })); }
public static async Task LogoutSessionAsync(Configuration config, MASDevice device, MASUser user) { var url = config.GetEndpointPath(config.OAuth.SystemEndpoints.UserSessionLogout); HttpUrlBuilder builder = new HttpUrlBuilder(); builder.Add("logout_apps", config.Mag.MobileSdk.IsSSOEnabled ? "true" : "false"); builder.Add("id_token", user.IdToken); builder.Add("id_token_type", user.IdTokenType); var headers = new Dictionary <string, string> { { HttpHeaders.Authorization, device.AuthHeaderValue }, { HttpHeaders.Accept, HttpContentTypes.Json }, { "mag-identifier", device.MagId }, { HttpHeaders.ContentType, HttpContentTypes.UrlEncoded } }; await HttpRequestFactory.RequestAsync <HttpResponseBaseData>(new HttpRequestInfo() { Method = HttpMethod.POST, Headers = headers, Url = url, Body = builder.ToString() }); }
public static async Task RevokeAccessTokenAsync(Configuration config, MASDevice device, MASUser user) { var url = config.GetEndpointPath(config.OAuth.SystemEndpoints.TokenRevocation); var accessToken = await user.GetAccessTokenAsync(); HttpUrlBuilder builder = new HttpUrlBuilder(url); builder.Add("token", accessToken); builder.Add("token_type_hint", "access_token"); var headers = new Dictionary <string, string> { { HttpHeaders.Authorization, device.AuthHeaderValue }, { HttpHeaders.Accept, HttpContentTypes.Json } }; await HttpRequestFactory.RequestAsync <HttpResponseBaseData>(new HttpRequestInfo() { Method = HttpMethod.DELETE, Headers = headers, Url = builder.ToString(), }); }