public async Task GetProfile() { var jwtToken = await _accessTokenService.GetAccessTokenAsync("jwt_token"); var user = await _httpClient.GetAsync <User>($"profile/getprofile/{UserId}", jwtToken); LoadCurrentObject(user); }
//loading actual contacts public async Task LoadAllContactsDB() { var jwtToken = await _accessTokenService.GetAccessTokenAsync("jwt_token"); var users = await _httpClient.GetAsync <List <User> >("contacts/getcontacts", jwtToken); LoadCurrentObject(users); }
public async Task <User> GetUserByJWTAsync() { //pulling the token from localStorage var jwtToken = await _accessTokenService.GetAccessTokenAsync("jwt_token"); if (jwtToken == null) { return(null); } jwtToken = $@"""{jwtToken}"""; return(await _loginViewModel.GetUserByJWTAsync(jwtToken)); }
public async Task <IEnumerable <Member> > Get(string clientId, string tokenUrl, string audience, string membershipUrl) { _logger.LogInformation("Getting token for client ID: " + clientId); TokenResponse accessTokenResponse = await _accessTokenService.GetAccessTokenAsync(clientId, tokenUrl, audience, Constants.LtiScopes.Nrps.MembershipReadonly, _keyVaultKeyString); if (accessTokenResponse.IsError) { _logger.LogError($"Could not get access token. Error: {accessTokenResponse.Error}. Error Desc: {accessTokenResponse.ErrorDescription}. Type: {accessTokenResponse.ErrorType}"); throw accessTokenResponse.Exception ?? new Exception($"Internal exception in the authentication flow to LMS: {accessTokenResponse.Error}"); } var httpClient = _httpClientFactory.CreateClient(EdnaExternalHttpHandler.Name); httpClient.SetBearerToken(accessTokenResponse.AccessToken); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(Constants.MediaTypes.MembershipContainer)); _logger.LogInformation("Getting members."); List <Member> members = new List <Member>(); do { using var response = await httpClient.GetAsync(membershipUrl); if (!response.IsSuccessStatusCode) { _logger.LogError("Could not get members."); throw new Exception(response.ReasonPhrase); } var content = await response.Content.ReadAsStringAsync(); var membership = JsonConvert.DeserializeObject <MembershipContainer>(content); members.AddRange(membership.Members); membershipUrl = GetNextMembershipUrlFromHeaders(response.Headers); }while (!string.IsNullOrEmpty(membershipUrl)); return(members .OrderBy(m => m.FamilyName) .ThenBy(m => m.GivenName)); }
public async Task UpdateProfile() { var jwtToken = await _accessTokenService.GetAccessTokenAsync("jwt_token"); await _httpClient.PutAsync <User>($"profile/updateprofile/{UserId}", this, jwtToken); }
public async Task LoadAllUsers() { var jwtToken = await _accessTokenService.GetAccessTokenAsync("jwt_token"); AllUsers = await _httpClient.GetAsync <List <User> >("user/getallusers", jwtToken); }