コード例 #1
0
        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();
        }
コード例 #2
0
        public TokenResponse CreateToken(GetTokenPost getTokenPost)
        {
            TokenInformation tokenInformation = authenticationService.AuthenticateUser(
                getTokenPost.Email, getTokenPost.Password
                );

            return(new TokenResponse
            {
                AccessToken = tokenInformation.AccessToken,
                UserRole = tokenInformation.Role
            });
        }
コード例 #3
0
 public async Task <TokenResponse> GetToken(GetTokenPost getTokenPost)
 {
     try
     {
         var url = $"{baseUrl}/token";
         return(await url
                .PostJsonAsync(getTokenPost)
                .ReceiveJson <TokenResponse>());
     }catch (FlurlHttpException e)
     {
         return(null);
     }
 }