Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "username": "<username>",
-- "recaptcha": "<recaptcha-token>",
-- "verificationmethod": "email or sms"
-- }
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'username', '<username>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'recaptcha', '<recaptcha-token>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'verificationmethod', 'email or sms'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://login.salesforce.com{{site}}/services/auth/headless/init/passwordless/login', 'application/json', @json
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
END
GO
Curl Command
curl -X POST
-d '{
"username": "<username>",
"recaptcha": "<recaptcha-token>",
"verificationmethod": "email or sms"
}'
https://login.salesforce.com{{site}}/services/auth/headless/init/passwordless/login
Postman Collection Item JSON
{
"name": "Passwordless Login - Initialize",
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true
}
},
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"username\": \"<username>\",\n \"recaptcha\": \"<recaptcha-token>\",\n \"verificationmethod\": \"email or sms\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}{{site}}/services/auth/headless/init/passwordless/login",
"host": [
"{{url}}{{site}}"
],
"path": [
"services",
"auth",
"headless",
"init",
"passwordless",
"login"
]
},
"description": "Submits the passwordless login data to the init/passwordless/login endpoint and returns a request identifier. At the same time, an OTP is sent out to the end users via email or sms. Passwordless login data is passed in the request body, and is formatted with JSON, with 3 keys: `username`, `recaptcha`, and `verificationmethod`. All 3 keys are strings.\n\nThis request returns JSON, and includes an identifier (request identifier)."
},
"response": [
]
}