<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom Connector with custom auth for CSRF Token in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4674#M2047</link>
    <description>&lt;P&gt;I've been receiving this error:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; authorized_at: 2023-06-28T14:17:44.718-05:00,
  authorization_status: exception,
  authorization_error: unexpected token at '&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;From what I understand, this is because Workato is expecting a JSON response and so parsing HTML response is failing. In the Debug I see Response Content-Type is text/html. So the question is, can Workato handle a text/html response? How can I handle this? I need to extract the Response Cookie and a value from the Form on the HTML page.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 20:54:01 GMT</pubDate>
    <dc:creator>fsantaana</dc:creator>
    <dc:date>2023-06-28T20:54:01Z</dc:date>
    <item>
      <title>Custom Connector with custom auth for CSRF Token</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4673#M2046</link>
      <description>&lt;P&gt;I am trying to build out a custom connector which needs to first make a GET call to retrieve a CSRFToken from both cookie and Form in the body, then respond with a POST passing back the cookie and the token form. I've been unable to accomplish this as the initial GET isn't storing the return. I've attempted using the after_response to handle response but have since changed my code. Any pointers will be greatly appreciated!!&lt;/P&gt;
&lt;P&gt;I've yet to code the POST as I've failed to even store the initial GET which is required for the POST.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Full connection line:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fsantaana_0-1687970502590.png" style="width: 400px;"&gt;&lt;img src="https://systematic.workato.com/t5/image/serverpage/image-id/493i97A0B55DBCEEC97E/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="fsantaana_0-1687970502590.png" alt="fsantaana_0-1687970502590.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Relevant Authorization section:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="ruby"&gt;   authorization: {
      type: "custom_auth",
      acquire: lambda do |connection|       
       response=get("/local/login/")
       
       {
         cookies: response['headers']['Set-Cookie'],
         body: response['body'],
         response:response
       }
        
       end,
     
     
      apply: lambda do |connection|

        if current_verb.match?("post") and current_url.include?("login")
          puts "apply if"  
          payload(
                username:connection["username"],
                password:connection["password"],
                csrftoken:connection["cookies"],
                next:"",
                this_is_the_login_form:1
              
            )
            headers('Referer': 'https://server.com/local/login/','Cookies': connection["cookie"])
        end
         puts "------End Apply------"
      end,
        
        refresh_on: [ 
            403,
            404,
            302,
            'Forbidden',
            'unexpected token',
            'this_is_the_login_form'
        ],
        detect_on: [
          404,  
          403,
          302,
          'Forbidden',
          'unexpected token',
          'this_is_the_login_form'
        ], 
    },
  test: lambda do |connection|
    get("system/serial/")
  end&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 14:28:05 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4673#M2046</guid>
      <dc:creator>fsantaana</dc:creator>
      <dc:date>2023-06-30T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Connector with custom auth for CSRF Token</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4674#M2047</link>
      <description>&lt;P&gt;I've been receiving this error:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; authorized_at: 2023-06-28T14:17:44.718-05:00,
  authorization_status: exception,
  authorization_error: unexpected token at '&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;From what I understand, this is because Workato is expecting a JSON response and so parsing HTML response is failing. In the Debug I see Response Content-Type is text/html. So the question is, can Workato handle a text/html response? How can I handle this? I need to extract the Response Cookie and a value from the Form on the HTML page.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 20:54:01 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4674#M2047</guid>
      <dc:creator>fsantaana</dc:creator>
      <dc:date>2023-06-28T20:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Connector with custom auth for CSRF Token</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4676#M2048</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/9319"&gt;@fsantaana&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Not sure, if this helps, as it doesn't sound like a "normal" API. However, you can instruct Workato not to parse the response in any way using the method:&amp;nbsp;&lt;A href="https://docs.workato.com/developing-connectors/sdk/sdk-reference/ruby_methods.html#response-format-raw" target="_blank" rel="noopener"&gt;response_format_raw&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;With that, you can parse the response yourself and do whatever is need to extract the required information.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 11:19:54 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4676#M2048</guid>
      <dc:creator>chris-wiechmann</dc:creator>
      <dc:date>2023-06-29T11:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Connector with custom auth for CSRF Token</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4677#M2049</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://systematic.workato.com/t5/user/viewprofilepage/user-id/5784"&gt;@chris-wiechmann&lt;/a&gt; ! that response_format_raw did the trick and I am now able to process the return for login!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 17:21:13 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/custom-connector-with-custom-auth-for-csrf-token/m-p/4677#M2049</guid>
      <dc:creator>fsantaana</dc:creator>
      <dc:date>2023-06-29T17:21:13Z</dc:date>
    </item>
  </channel>
</rss>

