Chilkat Online Tools

SQL Server / EPC 2.0 - Partner Sandbox - 19.4 November [External] / [Lender] Revoke Lender Authentication Token

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

    EXEC sp_OASetProperty @http, 'BasicAuth', 1
    EXEC sp_OASetProperty @http, 'Login', 'username'
    EXEC sp_OASetProperty @http, 'Password', 'password'

    DECLARE @req int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.HttpRequest', @req OUT

    DECLARE @jsonParam1 int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jsonParam1 OUT

    EXEC sp_OAMethod @jsonParam1, 'Emit', @sTmp0 OUT
    EXEC sp_OAMethod @req, 'AddParam', NULL, 'token', @sTmp0

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostUrlEncoded', @resp OUT, 'https://domain.com/', @req
    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 @req
        EXEC @hr = sp_OADestroy @jsonParam1
        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 @req
    EXEC @hr = sp_OADestroy @jsonParam1


END
GO

Curl Command

curl -X POST
	-u 'username:password'
	-H "Content-Type: application/x-www-form-urlencoded"
	--data-urlencode 'token={{lender_token}}'
https://domain.com/

Postman Collection Item JSON

{
  "name": "[Lender] Revoke Lender Authentication Token",
  "event": [
    {
      "listen": "test",
      "script": {
        "id": "7252b9c5-c9f3-49bc-a6a9-30e20a9cde88",
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "_postman_id": "e79391db-32a5-440c-bf2b-e68b0031293c",
  "request": {
    "auth": {
      "type": "basic",
      "basic": {
        "username": "{{lender_client_id}}",
        "password": "{{lender_client_secret}}",
        "showPassword": false
      }
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "type": "text",
        "value": "application/x-www-form-urlencoded",
        "disabled": true
      }
    ],
    "body": {
      "mode": "urlencoded",
      "urlencoded": [
        {
          "key": "token",
          "value": "{{lender_token}}",
          "type": "text"
        }
      ]
    },
    "url": "{{api_host}}/oauth2/v1/token/revocation"
  },
  "response": [
  ]
}