I want to connect to sharepiont site with browser authentication becouse mobile verifcation is on sharepiont. can any help me with this.

thanks Waqas

1 Answer 1


Use following method to authenticate browser.

  • ClientContext = Which holds the entire tenant/domain informations
  • Web = Holds the requested site details from the tenant
  • SecureString = Holds encrypt the plain password for the server authendication
  • SharePointOnlineCredentials = Its a authendication service

public ClientContext Auth(String uname, String pwd,string siteURL) { ClientContext context = new ClientContext(siteURL); Web web = context.Web; SecureString passWord = new SecureString(); foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c); context.Credentials = new SharePointOnlineCredentials(username, passWord); try { context.Load(web); context.ExecuteQuery(); Console.WriteLine("Olla! from " + web.Title + " site"); return context; } catch (Exception e) { Console.WriteLine("Something went wrong in Auth Module" + e); Console.ReadKey(); return null; } }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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