- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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>)"...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks all for your suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.