<?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 How to integrate external app with SAS Viya 3.5 using external OAuth token in Developers</title>
    <link>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728693#M1145</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm looking for samples, how to manage external app integration with Viya.&lt;/P&gt;
&lt;P&gt;In our scenario, external app and Viya 3.5 are configured&lt;/P&gt;
&lt;P&gt;to authenticate with third party OAuth Authentication provider (Microsoft ADFS).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scenario goes like this:&lt;/P&gt;
&lt;P&gt;1. User logs into external app.&lt;/P&gt;
&lt;P&gt;2. External app goes to the OAuth provider to authenticate user and obtain OAuth token.&lt;/P&gt;
&lt;P&gt;3. User is loged into the external app.&lt;/P&gt;
&lt;P&gt;4. External app calls Viya REST API to get list of the folders and reports on behalf of the user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here I'm stuck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I register external app as the client in Viya?&lt;/P&gt;
&lt;P&gt;I've found some examples how to register client:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    curl -X POST "https://localhost/SASLogon/oauth/clients" \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer &amp;lt;access-token-goes-here&amp;gt;" \
        -d '{
          "client_id": "app",
          "client_secret": "&amp;lt;secret-goes-here&amp;gt;",
          "scope": ["openid"],
          "authorized_grant_types": ["password"],
          "access_token_validity": 43199
         }'&lt;/PRE&gt;
&lt;P&gt;But as far as I understand, in this type of registration,&lt;/P&gt;
&lt;P&gt;the external app in order to get access token for the resource,&lt;/P&gt;
&lt;P&gt;it need to provide user name and password in the subsequent call, like in this example:&lt;/P&gt;
&lt;PRE&gt;   curl -X POST "https://server.example.com/SASLogon/oauth/token" \
      -H "Content-Type: application/x-www-form-urlencoded" \
      -d "grant_type=password&amp;amp;username=&amp;lt;user-id&amp;gt;&amp;amp;password=&amp;lt;password&amp;gt;" \
      -u "app:mysecret"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in our scenario, the app has only OAuth token, not the password.&lt;/P&gt;
&lt;P&gt;Documentation say, that there are some other types of authorized grants&lt;/P&gt;
&lt;P&gt;in the client registration call (I suppose Token Grant would fit my case)&lt;/P&gt;
&lt;P&gt;but I can't find the example.&lt;/P&gt;
&lt;P&gt;And documentation also say, that currently only the user:password grant is supported.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be grateful for advice/examples, how to register client&lt;/P&gt;
&lt;P&gt;and how to obtain access token from SASLogon having only OAuth token in hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Jacek&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Mar 2021 09:04:45 GMT</pubDate>
    <dc:creator>JacekGuzek</dc:creator>
    <dc:date>2021-03-24T09:04:45Z</dc:date>
    <item>
      <title>How to integrate external app with SAS Viya 3.5 using external OAuth token</title>
      <link>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728693#M1145</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm looking for samples, how to manage external app integration with Viya.&lt;/P&gt;
&lt;P&gt;In our scenario, external app and Viya 3.5 are configured&lt;/P&gt;
&lt;P&gt;to authenticate with third party OAuth Authentication provider (Microsoft ADFS).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scenario goes like this:&lt;/P&gt;
&lt;P&gt;1. User logs into external app.&lt;/P&gt;
&lt;P&gt;2. External app goes to the OAuth provider to authenticate user and obtain OAuth token.&lt;/P&gt;
&lt;P&gt;3. User is loged into the external app.&lt;/P&gt;
&lt;P&gt;4. External app calls Viya REST API to get list of the folders and reports on behalf of the user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here I'm stuck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I register external app as the client in Viya?&lt;/P&gt;
&lt;P&gt;I've found some examples how to register client:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    curl -X POST "https://localhost/SASLogon/oauth/clients" \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer &amp;lt;access-token-goes-here&amp;gt;" \
        -d '{
          "client_id": "app",
          "client_secret": "&amp;lt;secret-goes-here&amp;gt;",
          "scope": ["openid"],
          "authorized_grant_types": ["password"],
          "access_token_validity": 43199
         }'&lt;/PRE&gt;
&lt;P&gt;But as far as I understand, in this type of registration,&lt;/P&gt;
&lt;P&gt;the external app in order to get access token for the resource,&lt;/P&gt;
&lt;P&gt;it need to provide user name and password in the subsequent call, like in this example:&lt;/P&gt;
&lt;PRE&gt;   curl -X POST "https://server.example.com/SASLogon/oauth/token" \
      -H "Content-Type: application/x-www-form-urlencoded" \
      -d "grant_type=password&amp;amp;username=&amp;lt;user-id&amp;gt;&amp;amp;password=&amp;lt;password&amp;gt;" \
      -u "app:mysecret"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in our scenario, the app has only OAuth token, not the password.&lt;/P&gt;
&lt;P&gt;Documentation say, that there are some other types of authorized grants&lt;/P&gt;
&lt;P&gt;in the client registration call (I suppose Token Grant would fit my case)&lt;/P&gt;
&lt;P&gt;but I can't find the example.&lt;/P&gt;
&lt;P&gt;And documentation also say, that currently only the user:password grant is supported.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would be grateful for advice/examples, how to register client&lt;/P&gt;
&lt;P&gt;and how to obtain access token from SASLogon having only OAuth token in hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Jacek&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 09:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728693#M1145</guid>
      <dc:creator>JacekGuzek</dc:creator>
      <dc:date>2021-03-24T09:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to integrate external app with SAS Viya 3.5 using external OAuth token</title>
      <link>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728724#M1146</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/53010"&gt;@JacekGuzek&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I'll point out several resources that will help you out with understanding the authentication options and process.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are three authorization grant_types to consider: password (not recommended in anything other than a dev/test env), authorization code, and client_credentials. I'd recommend exploring the latter two. You can find a technical overview of all the options in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/255099"&gt;@MikeRoda&lt;/a&gt;&amp;nbsp;'s SASGF paper&amp;nbsp;&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4597-2020.pdf" target="_self"&gt;Behind the Front Door: Authentication Options with SAS Viya&lt;/A&gt;. There is also the&amp;nbsp;&lt;A href="https://developer.sas.com/apis/rest/#configuring-your-sas-environment-for-api-use" target="_self"&gt;Configuring Your SAS Environment for API Use&lt;/A&gt; and&amp;nbsp;&lt;A href="https://developer.sas.com/apis/rest/#authentication-and-access-tokens" target="_self"&gt;Authentication and Access Tokens&lt;/A&gt; sections of the &lt;A href="https://developer.sas.com/apis/rest/#getting-started" target="_self"&gt;SAS Viya Rest APIs Getting Started page&lt;/A&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, a blog post I wrote,&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2019/01/25/authentication-to-sas-viya/" target="_self"&gt;Authentication to SAS Viya: a couple of approaches&lt;/A&gt;&amp;nbsp;outlines the password and authorization code process. Further, you can refer to the series by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115394"&gt;@tarastclair&lt;/a&gt;, &lt;A href="https://blogs.sas.com/content/tag/build-custom-app/" target="_self"&gt;Building custom apps on top of SAS Viya&lt;/A&gt;, particularly &lt;A href="https://blogs.sas.com/content/sgf/2020/09/25/building-custom-apps-on-top-of-sas-viya-part-four-examples/" target="_self"&gt;Part Four, Examples&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, when reading through these resources remember:&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;exactly how you implement authentication depends heavily on the language your application was developed in and your your technical architecture and security paradigm.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 12:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728724#M1146</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2021-03-24T12:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to integrate external app with SAS Viya 3.5 using external OAuth token</title>
      <link>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728843#M1147</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/53010"&gt;@JacekGuzek&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214450"&gt;@joeFurbee&lt;/a&gt;&amp;nbsp;has provided an excellent answer with some authoritative resources.&amp;nbsp; I wanted to let you know about two more options for generating client / secret pairs with the various options available:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) The SASjs Viya Token generator&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a &lt;A href="https://sasjs.io/apps/#viya-client-token-generator" target="_self"&gt;SASjs streamed-web app&lt;/A&gt; that gives you an interface for creating a client with various scopes (the SAS groups are ready-fetched) and options.&lt;BR /&gt;&lt;BR /&gt;To deploy, just run these two lines of code and open the link from the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename vt url  "https://raw.githubusercontent.com/sasjs/viyatoken/master/runme.sas";
%inc vt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) The SASjs Macro Core library&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This contains a macro for generating the client / secret pair.&amp;nbsp; It's documented here:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mv__registerclient_8sas.html" target="_blank"&gt;https://core.sasjs.io/mv__registerclient_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To execute:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%* compile macros;
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc;

%* specific client with just openid scope;
%mv_registerclient(client_id=YourClient
  ,client_secret=YourSecret
  ,scopes=openid
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 18:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728843#M1147</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-03-24T18:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to integrate external app with SAS Viya 3.5 using external OAuth token</title>
      <link>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728997#M1148</link>
      <description>&lt;P&gt;Since your external app and SAS Viya are both using single sign-on to an external OIDC provider, you can make this work very well by configuring SAS Viya with Automatic Redirect so your users don't see the login page at all. See this link:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?cdcId=calcdc&amp;amp;cdcVersion=3.5&amp;amp;docsetId=calauthmdl&amp;amp;docsetTarget=n1pkgyrtk8bp4zn1d0v1ln4869og.htm&amp;amp;locale=en#n02zld6mf9swbrn1bu9ue2isnp8z"&gt;https://go.documentation.sas.com/?cdcId=calcdc&amp;amp;cdcVersion=3.5&amp;amp;docsetId=calauthmdl&amp;amp;docsetTarget=n1pkgyrtk8bp4zn1d0v1ln4869og.htm&amp;amp;locale=en#n02zld6mf9swbrn1bu9ue2isnp8z&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next question is:&amp;nbsp; Is your external app calling the Viya APIs from the browser client (javascript) or the server?&amp;nbsp; If from the browser client, you need not register a client at all. Just call the Viya APIs from the browser client. Those requests will be redirected around for authentication and use single sign-on, eventually coming back with the json you want. Read the section "Browser based applications" in the SGF paper that Joe linked to.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also a SAS Visual Analytics SDK that helps with this, particularly if you did have to deal with the login page coming up. See this link:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://developer.sas.com/guides/visual-analytics-sdk.html" target="_blank"&gt;https://developer.sas.com/guides/visual-analytics-sdk.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your external app is making calls to the SAS Viya APIs from the server, you will probably want to register that app as a client and use the authorization_code grant_type.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 09:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/728997#M1148</guid>
      <dc:creator>MikeRoda</dc:creator>
      <dc:date>2021-03-25T09:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to integrate external app with SAS Viya 3.5 using external OAuth token</title>
      <link>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/730074#M1149</link>
      <description>&lt;P&gt;Thank you all for your replies and guidance.&lt;/P&gt;
&lt;P&gt;We will be exploring the options described.&lt;/P&gt;
&lt;P&gt;So far I managed to register client application and checked it is working using postman.&lt;/P&gt;
&lt;P&gt;Now web app developer is investigating various scenarios&lt;/P&gt;
&lt;P&gt;how to use it in backend app.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Jacek&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 12:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-integrate-external-app-with-SAS-Viya-3-5-using-external/m-p/730074#M1149</guid>
      <dc:creator>JacekGuzek</dc:creator>
      <dc:date>2021-03-30T12:54:27Z</dc:date>
    </item>
  </channel>
</rss>

