tag:blogger.com,1999:blog-4455058894110083658.post8887918692331098672..comments2024-02-26T22:59:25.161+00:00Comments on Vardhaman Deshpande: Authenticating .NET CSOM in SharePoint OnlineVardhaman Deshpandehttp://www.blogger.com/profile/17919845281919756108noreply@blogger.comBlogger39125tag:blogger.com,1999:blog-4455058894110083658.post-78217902362268318442019-09-24T16:22:48.922+01:002019-09-24T16:22:48.922+01:00Hi Vardhaman, Thanks for this Post!!
I've bee...Hi Vardhaman, Thanks for this Post!!<br /><br />I've been struggling to connect a .Net app with SharePoint online. I have tried the code you posted, but I'm getting the following error: 'The remote server returned an error: (401) Unauthorized.'<br /><br />However, I know for sure that the SharePoint URL, username, and password are correct<br /><br />Please let me know if you have any suggestions.<br /><br />Kind regards,<br />Shaily Shah<br />Shaily Shahhttps://www.blogger.com/profile/11227711787378589423noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-3240994963812065892019-08-21T22:32:32.596+01:002019-08-21T22:32:32.596+01:00I am getting below error when i am running the abo...I am getting below error when i am running the above sample code<br /><br />Microsoft.SharePoint.Client.IdcrlException<br /> HResult=0x80048821<br /> Message=The sign-in name or password does not match one in the Microsoft account system.<br /> Source=Microsoft.SharePoint.Client.RuntimeRamahttps://www.blogger.com/profile/04711061273596054755noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-36293989812896932992017-08-15T15:14:58.347+01:002017-08-15T15:14:58.347+01:00hello. I get an error stating 'ActiveX contro...hello. I get an error stating 'ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.'.<br /><br />It breaks on this.webBrowser = new WebBrowser() in the ClaimsWebAuth method.<br /><br />I have tried adding the [STAThread] and few other things but no luck. Any thoughts? Anonymoushttps://www.blogger.com/profile/14405899664287286102noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-84815355105292036092017-08-15T15:11:28.016+01:002017-08-15T15:11:28.016+01:00Hello. When I get to the line of using(ClientCont...Hello. When I get to the line of using(ClientContext...) I get an error saying 'ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.'<br /><br />The issue is then it instantiate a new WebBrowser in the CLaimsWebAuth method.<br /><br />Any thoughts?Anonymoushttps://www.blogger.com/profile/14405899664287286102noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-32107761061390123352017-06-21T10:25:39.181+01:002017-06-21T10:25:39.181+01:00Hi Vardhaman,
We have a web application hosted on...Hi Vardhaman,<br /><br />We have a web application hosted on Azure Service which is accessing SharePoint (purchased E3 license) using CSOM 16.0(nuget package "Microsoft.SharePointOnline.CSOM")<br /><br />Example code :<br /><br />using (ClientContext clientContext = new ClientContext("https://yoursite.sharepoint..."))<br />{<br />SecureString passWord = new SecureString();<br /><br />foreach (char c in "yourpassword".ToCharArray()) passWord.AppendChar(c);<br /><br />clientContext.Credentials = new SharePointOnlineCredentials("loginname@yoursite.onmicrosoft.com", passWord);<br /><br />Web web = clientContext.Web;<br /><br />clientContext.Load(web);<br /><br />clientContext.ExecuteQuery();<br /><br />Console.WriteLine(web.Title);<br /><br />Console.ReadLine();<br />}<br /><br />it keep giving me following error, Please help<br /><br />'center' is an unexpected token. The expected token is '"' or '''. Line 7, position 12.<br /><br />Stack Trace for reference :<br /><br />[XmlException: 'center' is an unexpected token. The expected token is '"' or '''. Line 7, position 12.]<br />System.Xml.XmlTextReaderImpl.Throw(Exception e) +72<br />System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) +78<br />System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2) +127<br />System.Xml.XmlTextReaderImpl.ParseAttributes() +5382300<br />System.Xml.XmlTextReaderImpl.ParseElement() +428<br />System.Xml.XmlTextReaderImpl.ParseElementContent() +119<br />System.Xml.XmlTextReaderImpl.Read() +44<br />System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r) +880<br />System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o) +48<br />System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) +283<br />Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.DoGet(String url) +398<br />Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.RequestFederationProviderInfo(String domainname) +114<br />Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetFederationProviderInfo(String domainname) +324<br />Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.InitFederationProviderInfoForUser(String username) +74<br />Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String username, String password, String serviceTarget, String servicePolicy) +114<br />Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, SecureString password, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest) +302<br />Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh, Boolean alwaysThrowOnFailure) +360<br />Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext context, HttpWebRequest request) +487<br />Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream() +45<br />Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate() +382<br />Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest() +126<br />Microsoft.SharePoint.Client.ClientContext.ExecuteQuery() +234Vimalhttps://www.blogger.com/profile/15166217090619191687noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-14526864745653178362017-06-20T23:03:10.117+01:002017-06-20T23:03:10.117+01:00If you get a 403 and just created a new user accou...If you get a 403 and just created a new user account, try logging in to the site as that user first. Worked right after I did that. Not sure if there was a delay syncing the new licensed AAD user to SPO or what, but it worked right after I signed in the web browser first.Eric Schraderhttps://www.blogger.com/profile/01288427744431911888noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-48632977418005014782016-05-20T21:32:42.701+01:002016-05-20T21:32:42.701+01:00Hi I need to create a web service for external app...Hi I need to create a web service for external apps (other sites from the internet) invoke from my SharePoint site. The thing is that we have SharePoint Online. Can I do what u said in your post in SharePoint Online? If so, how? I'm very newbie in SharePoint.Unknownhttps://www.blogger.com/profile/02454744764586044523noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-40184194455810152362015-10-01T05:54:20.156+01:002015-10-01T05:54:20.156+01:00Hello Vardhaman,
I am new to sharepoint and tryin...Hello Vardhaman,<br /><br />I am new to sharepoint and trying to read List from sharepoint. But i'm getting exception "Cannot contact site at the specified URL https://xyz". Could you please help me here.<br /><br />Thanks,<br />KJAnonymoushttps://www.blogger.com/profile/11611892449190541444noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-48803801005776745072015-09-25T11:42:38.888+01:002015-09-25T11:42:38.888+01:00Thanks Vardhaman. This helped me a lotThanks Vardhaman. This helped me a lotARUNhttps://www.blogger.com/profile/10886177871729146135noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-21125486712492976912015-03-10T15:40:10.817+00:002015-03-10T15:40:10.817+00:00Hi Vardhaman,
How can I authenticate to SharePoin...Hi Vardhaman,<br /><br />How can I authenticate to SharePoint 2013 (On-prem) using ADFS as the authentication provider. In my code, I'm creating the ClientContext object but when I try to execute the query I'm getting a 403 Forbidden error.<br /><br />Thanks!Anonymoushttps://www.blogger.com/profile/11046024247028760604noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-91557262657101039882015-02-06T09:55:41.937+00:002015-02-06T09:55:41.937+00:00Hi Vardhaman,
I get following error in my service...Hi Vardhaman,<br /><br />I get following error in my service<br /><br />A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xxx.xxx.xx.xx:443<br /><br />Please help me to resolve this issueLuckyhttps://www.blogger.com/profile/11022330452261214264noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-49530483958327932422015-02-02T13:34:22.841+00:002015-02-02T13:34:22.841+00:00If any get the error for sharepoint-azure-msoidcli...If any get the error for sharepoint-azure-msoidclil-dll please refer below url:<br />https://stackoverflow.com/questions/18724064/sharepoint-azure-msoidclil-dll-missing/28278700#28278700Abhishekhttps://www.blogger.com/profile/06049594096544865599noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-9416966164852659142015-02-02T06:15:35.777+00:002015-02-02T06:15:35.777+00:00Hi Vardhaman,
Its working fine for me in my local...Hi Vardhaman,<br /><br />Its working fine for me in my local but currently when I am publishing my site on azure its throwing error "System.IO.FileNotFoundException: msoidcliL.dll". Do you have any idea about the same ? <br />FYI: we can't install anything on the Azure website.Abhishekhttps://www.blogger.com/profile/06049594096544865599noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-56451794016079336402014-12-11T06:46:07.982+00:002014-12-11T06:46:07.982+00:00I am getting 401 unauthorized error while connect...I am getting 401 unauthorized error while connecting to the Office365 using your code.<br />I am able to authenticate using login screen method.<br />But the requirement is to authenticate without using login screen pop up.<br />Kindly Help?Anonymoushttps://www.blogger.com/profile/06565592760950318474noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-18221269556765879512014-05-15T05:31:51.253+01:002014-05-15T05:31:51.253+01:00IDCRLException: "Identity Client Runtime Libr...IDCRLException: "Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in."<br /><br />This is the error I get just trying to construct a SharePointOnlineCredentials object - it was working fine previously. Any clues?Dylan Nicholsonhttps://www.blogger.com/profile/15028032592653986291noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-51361386245203997932014-02-23T21:32:03.389+00:002014-02-23T21:32:03.389+00:00@Brett
I have not tested it but you can maybe use...@Brett<br /><br />I have not tested it but you can maybe use the REST API for that. <br /><br />First get the RequestDigest of the SharePoint Page by following this link:<br /><a href="http://blogs.breeze.net/mickb/2012/11/20/SP2013GettingAFormDigestForUpdateRESTCalls.aspx" rel="nofollow">http://blogs.breeze.net/mickb/2012/11/20/SP2013GettingAFormDigestForUpdateRESTCalls.aspx</a><br /><br />and then pass that request digest to your jQuery.ajax call as shown here:<br /><br /><a href="http://msdn.microsoft.com/en-us/library/office/jj164022.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/office/jj164022.aspx</a>Vardhaman Deshpandehttps://www.blogger.com/profile/17919845281919756108noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-15599156131764649002014-02-06T16:45:27.728+00:002014-02-06T16:45:27.728+00:00What about if you were trying to authenticate Word...What about if you were trying to authenticate Wordpress using Sharepoint credentials. Could you do that using JS or PHP?Bretthttps://www.blogger.com/profile/09455439104371337011noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-48623748391884608962014-01-07T18:36:42.079+00:002014-01-07T18:36:42.079+00:00Works like a charm really! It would just make my d...Works like a charm really! It would just make my day if I can get rid of mentioning the password in this code. Can this be done somehow Vardhaman?bittusrkhttps://www.blogger.com/profile/08325975826159900379noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-54542399530636986842014-01-06T23:20:10.285+00:002014-01-06T23:20:10.285+00:00I found lot of articles on internet about SharePoi...I found lot of articles on internet about SharePoint authentication. Almost of all of them were pointing to same MSDN codebase that does not work with client service. It really helped me to resolve this issue.<br /><br />Great post Vardhaman. Thanks<br /><br />Atul SurekaAtul Surekahttps://www.blogger.com/profile/00699076851020049536noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-55093124450336842082013-12-02T01:42:51.728+00:002013-12-02T01:42:51.728+00:00Thanks, that contains good info about what the mso...Thanks, that contains good info about what the msoidcliL.dll issue may be. However, in my case, I cannot modify the registry on my shared server. And I can't install the "Client Components SDK". I see more people with the same issue, but I don't see a solution yet.Andynoreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-85609650455511854622013-12-01T10:48:40.345+00:002013-12-01T10:48:40.345+00:00@Andy
This might help?
http://tomaszrabinski.pl/...@Andy<br /><br />This might help?<br /><br /><a href="http://tomaszrabinski.pl/wordpress/2013/03/18/sharepointonlinecredentials-and-msoidclil-dll-file-not-found-exception" rel="nofollow">http://tomaszrabinski.pl/wordpress/2013/03/18/sharepointonlinecredentials-and-msoidclil-dll-file-not-found-exception/</a>Vardhaman Deshpandehttps://www.blogger.com/profile/17919845281919756108noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-13470754397235728972013-11-30T21:21:15.573+00:002013-11-30T21:21:15.573+00:00Like the 1st commenter, it works great on my PC. ...Like the 1st commenter, it works great on my PC. It does not work on my Windows Server. I get "FileNotFoundException: msoidcliL.dll" I have msoidcliL.dll (and the 2 Microsoft.SharePoint.Client.dll files) in the bin. VS will not let me add msoidcliL.dll as a reference. Thoughts?Andynoreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-61383584946452973632013-11-04T14:12:03.741+00:002013-11-04T14:12:03.741+00:00Hi All,
Bit late but hope someone of you can see ...Hi All,<br /><br />Bit late but hope someone of you can see this. <br />I have followed same code lines for SPO 2013 but I am getting an error at clientContext.ExecuteQuery();.<br /><br />Error says - The remote server returned an error: (403) Forbidden.<br /><br />Appreciate any help.<br /><br />Thanks,<br />vvAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-76277252101891511792013-09-23T09:55:58.237+01:002013-09-23T09:55:58.237+01:00Hi,
I getting the "Catastrophic failure (Exc...Hi,<br /><br />I getting the "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))" error in the SharePointOnlineCredentials. Do you know how I can fix it?<br /><br />And is it possible to use Active Directory's user in SharePointOnlineCredentials?<br /><br />Thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-47550912118273294572013-08-07T08:07:05.300+01:002013-08-07T08:07:05.300+01:00Anyone had any luck deploying this in an app to Of...Anyone had any luck deploying this in an app to Office365? I get "File Not Found Exception msoidcliL.dll" but works fine locally..Anonymousnoreply@blogger.com