BookmarkSubscribeRSS Feed
freshstarter
Obsidian | Level 7

Hello,

 

Is there any way to extract our own password via SAS EG in the SAS code?

 

I have to connect to Snowflake database using oauth mechansim where I have to pass my credentials along with client id to get the access token . I cant hardcode my password in the SAS code.  While logging to SAS EG, we enter our own credentials. So I'm thinking to extract the user credentails from SAS Login (DefaultAuth )  . Is that possible via any system macros (or) any other possible ways ? Thanks

5 REPLIES 5
SASKiwi
PROC Star

AFAIK this isn't possible. Some databases allow single signon so you can pass your computer session credentials onto the database. SQL Server is one such example but I'm not sure if this is possible with Snowflake.

 

An alternative approach would be to create an auth domain in SAS metadata linked to a service account and password and create Snowflake database connections, possibly also in metadata, using this auth domain. SAS metadata is a secure way of storing service accounts and passwords as they are stored in encrypted form. 

Patrick
Opal | Level 21

The clean way is as @freshstarter describes. 

 

A workaround could be to create the libname with your credentials in your EG autoexec and then only use the libref in your code. 

Don't store the password in clear text but encoded using Proc Pwencode

 

In a Unix/Linux environment: You could also create an environment variable via your .profile in your home directory that contains the encoded password and then use this environment variable in your libname statement in code.

 ...pw="%sysget(<environment variable created in .profile>)"...
Sajid01
Meteorite | Level 14

Hello @freshstarter 
There are multiple approaches to address your issue depending upon your environment and practices.
One approach would be to create an authentication domain. This is typically done at the admin level.
Please refer to the following references.

38204 - Using the AUTHDOMAIN= option with SAS/ACCESS® 9.2 engines  (For SAS 9.x)
creating domains and credentials using the sas-viya CLI (SAS Viya)
The other approach would be to create a libref in the autoexec.sas or use encoded passwords as suggested by @Patrick 

freshstarter
Obsidian | Level 7

Thanks all for your suggestion.

LinusH
Tourmaline | Level 20

Since you mention EG I assume you are in 9.4 (even though EG is supported for Viya4).

If you consider upgrading to Viya at some point, SSO is supproted there:

SAS Help Center: Authenticate to Microsoft Azure Using Single Sign-On

Ortherwise I think the AUTHDOMAIN option as already mentioned is the best method.

Data never sleeps

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1504 views
  • 7 likes
  • 5 in conversation