Example #1
0
        public async Task <string> GetClaims(ClaimsPrincipal principal)
        {
            try
            {
                var token = await _tokenService.GetAccessTokenAsync(principal, _azureAdOptions.ApiScopes);

                var client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                return(await client.GetStringAsync($"{_apiOptions.BaseUrl}/claims"));
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Example #2
0
        public async Task <string> GetUserProfile(ClaimsPrincipal principal)
        {
            try
            {
                var token = await _tokenService.GetAccessTokenAsync(principal, _adOptions.GraphScopes);

                var client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                return(await client.GetStringAsync($"{_graphUrl}/v1.0/me"));
            }
            catch (MsalUiRequiredException)
            {
                throw;
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }