<?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: Facing certificate not found error while calling APi in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/804115#M1428</link>
    <description>&lt;P&gt;&amp;nbsp;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/363459"&gt;@khandelwalanmol&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I'm adding three code blocks to this, one for each grant_type: authorization code, client credentials, and password. You can read more about client registration and creating access tokens in my blog post&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2021/09/24/authentication-to-sas-viya/" target="_self"&gt;Authentication to SAS Viya: a couple of approaches&lt;/A&gt;. All three grant types are covered in the post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your original code, I think you were attempting to use the password grant type. While the example I list below will work, please note that this is not secure and is being discouraged for use by the industry. Note that you must declare an authorization grant type when registering a client, so each of these code blocks would require a separate client id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Authorization code&lt;/H2&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
proc http url="https://sasserver.sas.com/SASLogon/oauth/token#authorization_code" 
method="POST" 
in='client_id=sasclient&amp;amp;client_secret=sasclientecret&amp;amp;grant_type=authorization_code&amp;amp;code=Mkm63aVEun'
out=out;
headers "Accept"="application/json";
run;

%put The return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Values to update: url, client_id, client_secret, code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Client Credentials&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-HTTP-with-OAUTH-to-get-an-access-token-from-a/td-p/778490" target="_self"&gt;code sample from this thread&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;

/* must include content-type/CT= option */
proc http 
 url="https://serviceaddress/oauth/access_token"
 in='grant_type=client_credentials&amp;amp;client_id=XXXXXXXX&amp;amp;client_secret=YYYYYYYY' 
 ct="application/x-www-form-urlencoded"
 out=resp
 method='POST'
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Values to update: url, client_id, client_secret&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Password&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616249" target="_self"&gt;code sample from this thread&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
proc http url="https://sasserver.sas.com/SASLogon/oauth/token#password" 
method="POST" 
auth_basic
Webusername="client_id"
webpassword="client_secret"
in='grant_type=password&amp;amp;username=viya_user&amp;amp;password=viya_password'
out=out;
headers "Accept"="application/json";
run;

%put return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Values to update: url, Webusername, Webpassword&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 15:36:45 GMT</pubDate>
    <dc:creator>joeFurbee</dc:creator>
    <dc:date>2022-03-25T15:36:45Z</dc:date>
    <item>
      <title>Facing certificate not found error while calling APi</title>
      <link>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/803322#M1426</link>
      <description>&lt;P&gt;I have been working on calling an API to fetch access token.&lt;/P&gt;&lt;P&gt;Here is my Http code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;options set=SSL_USE_SNI="0" set=SSL_SNI_HOSTNAME="sandbox.bcda.cms.gov"  ;
proc http
   		url="https://sandbox.bcda.cms.gov/auth/token" AUTH_BASIC
   		WEBUSERNAME="&amp;amp;client_id."
   		WEBPASSWORD="&amp;amp;client_secret."
   		out=apitoken
   		method="POST";
 		
   		headers "Accept"="application/json";
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is the error i have been getting.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ERROR: OpenSSL error 336134278 (0x14090086) occurred in SSL_connect/accept at line 5388, the error message is "error:14090086:SSL
routines:ssl3_get_server_certificate:certificate verify failed".
ERROR: Secure communications error status 807ff008 description "OpenSSL error 336134278 (0x14090086) occurred in SSL_connect/accept
at line 5388, the error message is "error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed"."
ERROR: Encryption run-time execution error
ERROR: Call to tcpSockContinueSSL failed.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Any suggestions what could be the possible issue.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 12:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/803322#M1426</guid>
      <dc:creator>khandelwalanmol</dc:creator>
      <dc:date>2022-03-22T12:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Facing certificate not found error while calling APi</title>
      <link>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/803890#M1427</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/363459"&gt;@khandelwalanmol&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Sorry for the delay. I just saw this question. Let me take a look in my environment and see if I can get it to work.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/803890#M1427</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2022-03-24T19:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Facing certificate not found error while calling APi</title>
      <link>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/804115#M1428</link>
      <description>&lt;P&gt;&amp;nbsp;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/363459"&gt;@khandelwalanmol&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I'm adding three code blocks to this, one for each grant_type: authorization code, client credentials, and password. You can read more about client registration and creating access tokens in my blog post&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2021/09/24/authentication-to-sas-viya/" target="_self"&gt;Authentication to SAS Viya: a couple of approaches&lt;/A&gt;. All three grant types are covered in the post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your original code, I think you were attempting to use the password grant type. While the example I list below will work, please note that this is not secure and is being discouraged for use by the industry. Note that you must declare an authorization grant type when registering a client, so each of these code blocks would require a separate client id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Authorization code&lt;/H2&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
proc http url="https://sasserver.sas.com/SASLogon/oauth/token#authorization_code" 
method="POST" 
in='client_id=sasclient&amp;amp;client_secret=sasclientecret&amp;amp;grant_type=authorization_code&amp;amp;code=Mkm63aVEun'
out=out;
headers "Accept"="application/json";
run;

%put The return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Values to update: url, client_id, client_secret, code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Client Credentials&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-HTTP-with-OAUTH-to-get-an-access-token-from-a/td-p/778490" target="_self"&gt;code sample from this thread&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename resp temp;

/* must include content-type/CT= option */
proc http 
 url="https://serviceaddress/oauth/access_token"
 in='grant_type=client_credentials&amp;amp;client_id=XXXXXXXX&amp;amp;client_secret=YYYYYYYY' 
 ct="application/x-www-form-urlencoded"
 out=resp
 method='POST'
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Values to update: url, client_id, client_secret&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Password&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616249" target="_self"&gt;code sample from this thread&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
proc http url="https://sasserver.sas.com/SASLogon/oauth/token#password" 
method="POST" 
auth_basic
Webusername="client_id"
webpassword="client_secret"
in='grant_type=password&amp;amp;username=viya_user&amp;amp;password=viya_password'
out=out;
headers "Accept"="application/json";
run;

%put return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Values to update: url, Webusername, Webpassword&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 15:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/804115#M1428</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2022-03-25T15:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Facing certificate not found error while calling APi</title>
      <link>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/804117#M1429</link>
      <description>&lt;P&gt;I didn't realise the OP was referring to Viya&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if so, there are some ready made macros in SASjs for client registration, authentication &amp;amp; refresh:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*&amp;nbsp;&lt;A href="https://core.sasjs.io/mv__tokenauth_8sas.html" target="_blank"&gt;https://core.sasjs.io/mv__tokenauth_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;*&amp;nbsp;&lt;A href="https://core.sasjs.io/mv__tokenrefresh_8sas.html" target="_blank"&gt;https://core.sasjs.io/mv__tokenrefresh_8sas.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 15:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/804117#M1429</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2022-03-25T15:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Facing certificate not found error while calling APi</title>
      <link>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/805768#M1430</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/363459"&gt;@khandelwalanmol&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to check if you were able to attempt the suggestions made in the replies to your post. If you have further issues, please let us know; otherwise, you can mark the thread as resolved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 00:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Facing-certificate-not-found-error-while-calling-APi/m-p/805768#M1430</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2022-04-04T00:53:28Z</dc:date>
    </item>
  </channel>
</rss>

