BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
js5
Pyrite | Level 9 js5
Pyrite | Level 9

Hello,

 

I am trying to set up a program calling rest API in order to trigger a databricks job. The issue I am facing is that I cannot encrypt the token and it only works if the oauth_bearer value is provided in plaintext. This gives me error 401:

filename pwfile 'testpw.txt';

proc pwencode in="foo" out=pwfile method=sas005;
run;

data _null_;
	infile pwfile truncover;
	input line :$200.;
	call symputx('dbxtoken',line);
run;

filename jpl 'testin.json';

proc json out=jpl;
	write values "job_id" "1234";
run;

filename jrp 'testout.json';

proc http url="https://dbc-abcd-1234.cloud.databricks.com/api/2.2/jobs/run-now"
	method=post
	in=jpl
	out=jrp
	oauth_bearer="&dbxtoken";
run;

Whereas this works as intended:

filename jpl 'testin.json';

proc json out=jpl;
	write values "job_id" "1234";
run;

filename jrp 'testout.json';

proc http url="https://dbc-abcd-1234.cloud.databricks.com/api/2.2/jobs/run-now"
	method=post
	in=jpl
	out=jrp
	oauth_bearer="&foo";
run;

Is this expected? And if so, what would be the alternative for not having to store the service principal secret in plaintext? Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

The 3rd party app with which SAS communicates doesn't "know" how SAS password encoding and decoding works. SAS must therefore send the password cleartext. This is also true for SAS Access where you're passing something like pw="{SAS005}6DDE667...." SAS will during runtime decode the password and send it cleartext to the database.

 

It appears such decoding is not implemented for proc http with oauth_bearer parameter and therefore you can't use a SAS encoded password but must send it cleartext.

 

Based on some Googling Databricks supports OAuth Token Federation - but SAS only fully supports it in the Viya version. ...and it would also require some setup.

 

For OAuth Bearer Token you could store your token in a secure location and access it during runtime (=not directly storing it in the script). Another option would be to wrap your code into a SAS macro that you compile secure into some permanent SAS catalogue - with the token provided as macro parameter when you compile the macro.

 

View solution in original post

5 REPLIES 5
SASKiwi
PROC Star

What does the Databricks job do? What about using SAS/ACCESS Interface to Databricks to execute a stored procedure running the processes you want instead? 

js5
Pyrite | Level 9 js5
Pyrite | Level 9

The job copies data from SQL server bound as catalog to another schema. We are testing direct upload via ODBC in parallel, but unfortunately the performance is insufficient.

SASKiwi
PROC Star

I recommend you engage with Tech Support regarding the slow upload.

js5
Pyrite | Level 9 js5
Pyrite | Level 9

I did engage both SAS and Databricks tech support, but I am exploring alternatives in parallel.

Patrick
Opal | Level 21

The 3rd party app with which SAS communicates doesn't "know" how SAS password encoding and decoding works. SAS must therefore send the password cleartext. This is also true for SAS Access where you're passing something like pw="{SAS005}6DDE667...." SAS will during runtime decode the password and send it cleartext to the database.

 

It appears such decoding is not implemented for proc http with oauth_bearer parameter and therefore you can't use a SAS encoded password but must send it cleartext.

 

Based on some Googling Databricks supports OAuth Token Federation - but SAS only fully supports it in the Viya version. ...and it would also require some setup.

 

For OAuth Bearer Token you could store your token in a secure location and access it during runtime (=not directly storing it in the script). Another option would be to wrap your code into a SAS macro that you compile secure into some permanent SAS catalogue - with the token provided as macro parameter when you compile the macro.

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 818 views
  • 0 likes
  • 3 in conversation