SCIMReferenceCode icon indicating copy to clipboard operation
SCIMReferenceCode copied to clipboard

Autorization on Azure Ad failled

Open infosam1976 opened this issue 2 years ago • 0 comments

I have deploy the sample on Ad Azure free for testing and I get an error when call the api with WPF application (also with blazor app with identitifcation)

error : AuthenticationFailed: 'IDX10503: Signature validation failed. Keys tried: 'Microsoft.IdentityModel.Tokens ..

I'm get token with token and I place this one in user call :

private async Task GetToken() { HttpClient cli = new HttpClient();

        HttpResponseMessage response = await cli.GetAsync("https://microsoftscimwebtest.azurewebsites.net/scim/Token");

        response.EnsureSuccessStatusCode();

        string token = await response.Content.ReadAsStringAsync();

        JObject obj = JObject.Parse(token);

        return obj.GetValue("token").ToString();
    }

    private  async void Button_Click(object sender, RoutedEventArgs e)
    {
        var token = await GetToken();

        using (var client = new HttpClient())
        {
            //client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");

            // await client.GetAsync("https://microsoftscimwebtest.azurewebsites.net/scim/Users?attributes=userName");
            var result = await client.GetAsync("https://microsoftscimwebtest.azurewebsites.net/scim/Groups");

            if (!result.IsSuccessStatusCode)
            {
                throw new ArgumentException("error");
            }

            var jsonResult = await result.Content.ReadAsStringAsync();
        }
    }

Tank's for you help

infosam1976 avatar Sep 06 '23 13:09 infosam1976