1

I'm new to using SharePoint. Is it possible to get an authenticated ClientContext without a username and password? I would like to make my app automatically access SharePoint if the machine is already logged in to Office 365 (word,excel,outlook) or to SharePoint in a web browser. I need the authenticated ClientContext so i can pass the credentials to a DownloadFile method.

Private Sub DownloadFile(webUrl As String, credentials As ICredentials, fileRelativeUrl As String)
    Using client = New WebClient()
        client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
        client.Headers.Add("User-Agent: Other")
        client.Credentials = credentials 
        client.DownloadFile(webUrl, fileRelativeUrl)
    End Using
End Sub

Thanks in advance.

Trevor
  • 7,777
  • 6
  • 31
  • 50
Jon
  • 11
  • 1
  • `Is it possible to get an authenticated ClientContext without a username and password?`, short answer is ***no***. If that was the case that would be a security issue, a big one at that. Other than that you could create a function to return the ClientContext you then can use anywhere you would need. – Trevor Feb 16 '17 at 16:32

0 Answers0