Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to have a console app that can login in, authenticate and update some custom lists. I can't find any good examples that work.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

The only tricky part for accessing SharePoint Online from the Client Object Model will be the authentication. There is no direct method of authenticating with SharePoint Online from the CSOM so Microsoft has released a work around.

You can find the details and code here: http://blogs.msdn.com/b/cjohnson/archive/2011/05/03/authentication-with-sharepoint-online-and-the-client-side-object-model.aspx

So what it basically does is:

  1. Opens up a browser Instance

  2. Authenticates with the browser

  3. Grabs the authentication cookie and passes it to the Client Object Model.

The rest of the tasks should be quite straight forward. You can find many code samples here: http://msdn.microsoft.com/en-us/library/ee537013.aspx

UPDATE: You this technique to allow the authentication to happen without a human running the console app: http://blogs.msdn.com/b/cjohnson/archive/2011/05/14/part-2-headless-authentication-with-sharepoint-online-and-the-client-side-object-model.aspx

share|improve this answer
    
Where would I specify the login/password? I don't see that in the example. It gets through the process, but then gives me a 403 Access is denied. I'm assuming because it's not authenticated properly. Thanks! –  Shane Nov 7 '12 at 15:09
    
Did you check the first link for the authentication sample? See here for direct jump to the page: code.msdn.microsoft.com/Remote-Authentication-in-b7b6f43c/… –  Vardhaman Deshpande Nov 7 '12 at 16:11
    
Yes, that is what I am using. Does the window that it puts up supposed to be where you manually login? Is that how it gets it? Mine just opens really fast then closes, but still. If this requires user interactivity, then this won't work. –  Shane Nov 7 '12 at 16:25
    
Yes you will have to login if you are not already authenticated with Internet Explorer. Once you log in, the cookie will be saved and you wont have to login again till it expires. My guess is that you are already logged in with a different account in IE and that's why the window is closing fast and you are getting the access denied error. –  Vardhaman Deshpande Nov 7 '12 at 16:32
    
so for this technique to work, you have to have a user logging in? Is there no way to authenticate with SP remotely with a nightly job. I just want to keep a custom list in sync with a SQL table. –  Shane Nov 7 '12 at 16:39
show 2 more comments

If you will be running this console app on the SharePoint server then use the SharePoint Object Model.

On the other hand, if this app will be accessing SharePoint remotely then use CSOM. For information about how to use CSOM, see the following MS Pattern & Practices article.

Basically, the way CSOM works is:

  1. Create a context by specifying the SharePoint site.
  2. Create a query.
  3. Execute the query. Which will send that query to the SP server (more specifically to the client.svc), execute the query, and return the result back to you.
share|improve this answer
    
This is SP 2010 online, so it wil be remote, not on that server. –  Shane Nov 6 '12 at 21:29
    
Then, in that case use CSOM. –  Hossein Aarabi Nov 6 '12 at 21:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.