403 Forbidden Error in SP Client Object Model Skip to main content
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Arvind MaheshwariArvind Maheshwari 

403 Forbidden Error in SP Client Object Model

SharePoint client object model code which was working earlier now throws 403 forbidden error after OKTA integration. Given below is sample code:
var xmlDocument = new XmlDocument();
                XDocument xdoc = new XDocument();
                string siteURL = "http://<site-collection-url> (http://%3csite-collection-url%3e)";
                using (ClientContext context = new ClientContext(siteURL))
                    Uri siteURI = new Uri(siteURL);
                    Uri xmlDocURI = new Uri(" http://<site-collection-url>/XMLDocLibraryName/MegaMenu.xml (%20http:/%3csite-collection-url%3e/XMLDocLibraryName/MegaMenu.xml)");
                    string xDocURL = xmlDocURI.AbsoluteUri;
                   context.Credentials = new NetworkCredential(farm-account, farm-acc-pwd);                
It fails on ExecuteQuery and throws 403 forbidden error.

I guess OKTA will provide some kind of token to authorize these request. Do we have any API from OKTA which generates token?
Marius VoinescuMarius Voinescu (Okta, Inc.)
This looks like a configruation error and I would suggest doulbe checking the deployment guide for the Sharepoint, and if further assistance is needed to open a ticket with Okta.