Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Classic ASP) SharePoint Online AuthenticationDemonstrates how to authenticate with SharePoint Online. The end result of authentication is to establish an HTTP cookie, named "SPOIDCRL", that contains a binary security token to be sent in subsequent SharePoint HTTPS requests. The SPOIDCRL cookie can be persisted to a file and re-used in subsequent application runs. Important: This example uses a method, SharePointOnlineAuth, that is introduced in Chilkat v9.5.0.73. Also Important: Chilkat realizes there may be cases where your situation is such that it does not work, and something additional is required to make it work. If the example does not work out-of-the-box, please send email to support@chilkatsoft.com. The information logged to the LastErrorText property has been carefully crafted to help solve problems quickly. Also, the JSON argument to the SharePointOnlineAuth method provides a means to include additional information, whatever it may be, to handle future unknown situations.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% ' This requires the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http") set http = Server.CreateObject("Chilkat.Http") ' Change these things... ' Make sure to use "https" and end in a "/". siteUrl = "https://mydomain.sharepoint.com/" ' The username is an email address. username = "username@mydomain.com" ' The jsonExtra is for future use, if extra information is required for particular integrations. ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject") set jsonExtra = Server.CreateObject("Chilkat.JsonObject") ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.SecureString") set ssPassword = Server.CreateObject("Chilkat.SecureString") success = ssPassword.Append("mypassword") ' Set properties to save/send cookies, and specify a cookie directory. ' If the CookieDir = "memory", then the SPOIDCRL cookie is persisted in memory for this HTTP object instance only. ' To persist the SharePoint authentication cookie for other HTTP objects, and for future application runs, ' set the CookieDir equal to a directory path (not a specific file path, but a directory path where cookie files ' are to be created). http.SaveCookies = 1 http.SendCookies = 1 http.CookieDir = "memory" ' The SharePointOnlineAuth method is introduced in Chilkat v9.5.0.73 success = http.SharePointOnlineAuth(siteUrl,username,ssPassword,jsonExtra) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>" Response.End End If Response.Write "<pre>" & Server.HTMLEncode( "Success! We have the SPOIDCRL cookie...") & "</pre>" ' ----------------------------------------------------------------------------------------------------------- ' IMPORTANT: ' The purpose of the SharePointOnlineAuth method is to establish the SPOIDCRL cookie that will automatically be ' included in subsequent requests using the *** same HTTP object instance. *** ' If later you create a new HTTP object instance, then you'll need to re-establish the SPOIDCRL cookie before sending ' a Sharepoint HTTP request. ' ----------------------------------------------------------------------------------------------------------- ' SharePoint authenticated requests may now be sent because the authentication cookie is automatically included. ' For example: ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder") set sbResponseXml = Server.CreateObject("Chilkat.StringBuilder") ' If your Sharepoint site is within a site collection, then use "https://mydomain.sharepoint.com/sites/teamA/_api/web/GetFolderByServerRelativeUrl('/sites/teamA/Documents')/Files" where "teamA" is the name of the site. success = http.QuickGetSb("https://mydomain.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/Documents')/Files",sbResponseXml) If (success = 0) Then Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>" Response.End End If Response.Write "<pre>" & Server.HTMLEncode( "Response status code = " & http.LastStatus) & "</pre>" ' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Xml") set xml = Server.CreateObject("Chilkat.Xml") success = xml.LoadSb(sbResponseXml,1) Response.Write "<pre>" & Server.HTMLEncode( xml.GetXml()) & "</pre>" %> </body> </html> |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.