Error 403 'Forbidden" when calling Users API

I am using a .NET Framework MVC App and calling a GetUser method to access the API. When make the HTTP request I get a error 403 “Forbidden” in the response. I am using the SSWS token from Postman and even did the Oauth2.0 get bearer token from the Okta docs but I still get the same result. What’s the best approach here to successfully make API calls from my app?

Are you using our .NET Management SDK? If so, how have you configured the OktaClient (make sure you censor your actual SSWS token!)?

1 Like

I found the solution using the .NET SDK OktaClient.


        [System.Web.Mvc.Authorize]
        public async Task<string> GetUser()
        {
            var client = new OktaClient(new OktaClientConfiguration
            {
                OktaDomain = "https:/{OKTA}.okta.com",
                Token = _oktaApiKey,
                AuthorizationMode = AuthorizationMode.SSWS,
                ClientId = _clientId,
                Scopes = new List<string> { "okta.users.read", "okta.users.manage" },
            });

            var response = await client.GetAsync<Okta.Sdk.User>(new HttpRequest {Uri = "/api/v1/users/me"});

            return  response.Id.ToString();
        }
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.