async Task Login() { GetTokenPost tokenPost = new GetTokenPost { Email = Username, Password = Password }; TokenResponse tokenResponse = await _apiService.Create <TokenResponse>(tokenPost); Application.Current.Properties["access_token"] = tokenResponse.AccessToken; Application.Current.Properties["userRole"] = tokenResponse.UserRole; Application.Current.MainPage = new MainPage(); }
public TokenResponse CreateToken(GetTokenPost getTokenPost) { TokenInformation tokenInformation = authenticationService.AuthenticateUser( getTokenPost.Email, getTokenPost.Password ); return(new TokenResponse { AccessToken = tokenInformation.AccessToken, UserRole = tokenInformation.Role }); }
public async Task <TokenResponse> GetToken(GetTokenPost getTokenPost) { try { var url = $"{baseUrl}/token"; return(await url .PostJsonAsync(getTokenPost) .ReceiveJson <TokenResponse>()); }catch (FlurlHttpException e) { return(null); } }