How can I get ClientContext in Office 365 with fixed credentials (do not request a user)

I am creating a prototype tool that runs every few minutes and goes to the 365 website of the office and extracts and processes the information.

Right now, I started with the MSDN guide, “Remote authentication with SharePoint Online using claims-based authentication , which points to a very useful sample code that receives a clientcontext object based on user registration and then retrieves a cookie.

I want to be able to run my code in the task scheduler so that you can specify the username and password in the configuration somewhere.

Does anyone have code to do this or a starting point. sort of

using (ClientContext ctx = SomeClass.GetContext(targetSiteUrl, username, password))
{
    if (ctx != null)
    {
        //dostuffhere
    }
}

I saw this blog post Auto-login for SharePoint using on-demand authentication , but the code on the site does not seem complete / I cannot make it work

I just want to note that I am referring to the current version of Office 365 (based on 2010), and not the new beta version of 2013

+5
source share
3 answers

So, do you want to allow the user access to something if they are not a registered user in SharePoint? if so, you might want to take a look at enhancing existing user rights in code.

+1
source

, . ou MSOnlineHelper,

+1

Use SharePointOnlineCredentials to instantiate clientContext.Credentials.

The SharePointOnlineCredentials class represents an object that provides credentials for accessing SharePoint Online resources.

+1
source

All Articles