Skip to main content

What Info is Available from my APEX Social Sign-In Provider

Updated 2 min readMarkdown
What Info is Available from my APEX Social Sign-In Provider

Familiar title? Disclaimer, this blog is 100% inspired by Anton Nielsens's amazing blog here
http://c2anton.blogspot.com/2019/09/what-info-is-available-from-my-apex.html

I thought I could jazz up the results a bit in a table format (well slightly more formatted).

How it works: Depending on the scopes you ask for, your Social Sign-In Provider gives you a wad of JSON following authentication. You have one shot at reading the details... in your post_authentication procedure.

In my variant of Anton's work, we have to

  • Create an application item A_SOCIAL_INFO

  • Create a Dynamic Content region on Page 1 with PL/SQL Function Body returning a CLOB of the below code

      RETURN :A_SOCIAL_INFO;
    
  • Edit your Social Sign-In authentication scheme

  • Add post_authentication as your Post-Authentication Procedure Name

      post_authentication
    
  • Edit your Social Sign-In authentication scheme and add the following PL/SQL

    procedure post_authentication is
      l_index    varchar2(32767);
      l_kind     number;
      l_value    varchar2(32767);
    begin
      l_index := apex_json.g_values.first;

      :A_SOCIAL_INFO :=
        '<table class="t-Report-report">
          <thead>
            <tr>
              <th class="t-Report-colHead">Name</th>
              <th class="t-Report-colHead">Data Type</th>
              <th class="t-Report-colHead align="left">Value</th>
            </tr>
          </thead>
          <tbody>';

      for i in 1..(apex_json.g_values.count) loop
        l_kind  := apex_json.g_values(l_index).kind;

        if l_kind = 4 then
          l_value := apex_json.g_values(l_index).number_value;
        elsif l_kind = 5 then
          l_value := apex_json.g_values(l_index).varchar2_value;
        else
          l_value := null;
        end if;

        :A_SOCIAL_INFO :=
          :A_SOCIAL_INFO ||
          '<tr>' ||
            '<td class="t-Report-cell" align="left">' || l_index || '</td>' ||
            '<td class="t-Report-cell" align="left">' || CASE l_kind WHEN 4 THEN 'Number' WHEN 5 THEN 'Varchar2' ELSE TO_CHAR(l_kind) END || '</td>' ||
            '<td class="t-Report-cell" align="left">' || l_value || '</td>' ||
          '</tr>';

        l_index :=  apex_json.g_values.next(l_index);
      end loop;

      :A_SOCIAL_INFO :=
        :A_SOCIAL_INFO ||
        '      </tbody>
        </table>';


    exception
      when others then
        :A_SOCIAL_INFO :=
          :A_SOCIAL_INFO || ' err: ' ||sqlerrm;
    end;

ENJOY!

241 views

About the author

  • With around 20 years on the job, Matt is one of the most experienced software developers at Pretius. He likes meeting new people, traveling to conferences, and working on different projects.

    He’s also a big sports fan (regularly watches Leeds United, Formula 1, and boxing), and not just as a spectator – he often starts his days on a mountain bike, to tune his mind.

No comments yet. Be the first to comment.