I am developing a Visual Basic web application, and i have managed to successfully get the authentication part done. The code i have as of now:

<STAThread()> Public Sub getAuthentication()

    Using ctx As ClientContext = ClaimClientContext.GetAuthenticatedContext("https://sample.sharepoint.com")

        If ctx IsNot Nothing Then

            'able to remote login
            Dim web As Web = ctx.Web


            Dim siteUrl As String = "https://sample.sharepoint.com/teams/collabs/SupplierManagement/database/Americas%20WIKI/Home.aspx"

            Dim clientContext1 As New ClientContext(siteUrl)
            Dim oWebsite As Web = clientContext1.Web
            Dim collList As ListCollection = oWebsite.Lists


        End If
    End Using
End Sub

But it throws Error 403 at the line of code below, which means i am not authenticated. Can anyone please help? I have been stuck for days now, and i am new to this.



Below code will help you to retrieve all properties of a list in website.

Dim siteUrl As String = "http://MyServer/sites/MySiteCollection"
Dim clientContext As New ClientContext(siteUrl)
Dim oWebsite As Web = clientContext.Web
Dim collList As ListCollection = oWebsite.Lists

Dim oList As SP.List
For Each oList In collList
Console.WriteLine("Title: {0} Created: {1}", oList.Title, oList.Created.ToString())
Next oList

Note:- In your code, SiteUrl is the problem.

  • Hi @Hardik, thank you for your reply. I have tried the following code before from MSDN. I tried setting the siteUrl as "sample.sharepoint.com", it still gives me Error 403 after the authentication is done using the code i provided. – Tan Stanley Apr 3 '17 at 7:36
  • You have mentioned URLs in your code at two different locations. Both must be same as you are accessing the subsite not the main site (Understood from your code). If you are authenticating the main site then it is not sure that you do have the same access on the subsite as well so try to authenticate the site from which you want data. – Hardik Apr 3 '17 at 7:38
  • I just tried, and used the same siteUrl. Upon hitting the second executeQuery(), it hits the same error. – Tan Stanley Apr 3 '17 at 7:58
  • hi Hardik, it will work if it is using the same ClientContext. – Tan Stanley Apr 3 '17 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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