BookmarkSubscribeRSS Feed
Amulraj
Fluorite | Level 6

I created client id and password following the steps mentioned in the below blog

https://blogs.sas.com/content/sgf/2023/02/07/authentication-to-sas-viya/

 

After generating the access token ran a sas api to run a job definition 

import http.client

conn = http.client.HTTPConnection("example.com")

payload = "{\n  \"name\": \"proc print example\",\n  \"description\": \"ods output with age 14 cutoff\",\n  \"jobDefinitionUri\": \"/jobDefinitions/definitions/2cbe5f60-1391-42db-a857-271e83eb7e48\",\n  \"arguments\": {\n    \"AGE\": \"14\"\n  }\n}"

headers = {
    'Delegate-Domain': "",
    'Content-Type': "application/json",
    'Authorization': "Bearer <access-token-goes-here>",
    'Accept': "application/json, application/vnd.sas.job.execution.job+json, application/vnd.sas.error+json"
}

conn.request("POST", "/jobExecution/jobs", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

The output i recieved is 

{
  "version": 2,
  "httpstatusCode": 500,
  "errorCode": 30081,
  "message": "Invalid user: \"clientid\"",
  "details": [
    "traceId: cf313c5d4b62431f",
    "path: /launcher/processes",
    "path: /compute/contexts/8c3023b8-9fe1-4b4b-ba67-7ced166e9b49/sessions",
    "correlator: 531e7c41-d3d9-48ed-86e6-bdce959e48d7"
  ]
}

 Details of the job definition 

proc print data=sashelp.iris (obs=&n_rows);
        title "First &n_rows Rows of the Iris Dataset";
    run;

When i create access token using sas user id and password, the job request executes successfully.  But the request gets failed while using auth token of client id. What necessary Authorization should be given to client id to run a job in compute.

 

2 REPLIES 2
joeFurbee
Community Manager

Hi @Amulraj,

Please reference the steps in this Jupyter notebook to create the client id that will include the proper credentials to generate a valid access and refresh token. You'll need to have admin rights when creating the client id. Also in that repository there is an example end-to-end use case for job creation and execution. The scripts are available for Postman, Python, and R.


Join us for SAS Community Trivia
SAS Bowl XLVI, Causal Analysis
Wednesday, December 18, 2024, at 10 a.m. ET | #SASBowl

Amulraj
Fluorite | Level 6

Hi @joeFurbee ,

 

I performed the same activity as mentioned in the notebook using sasboot to create client id, job definition. while executing the job definition as a job request  using the access token from the client id generated ,  i am getting the following error in postman

"error": {
"errosCode:30154,
"message": "Failed to retrieve identifier information user: \"@currentUser\"",
"details":[
"traceld: 50df36fa9c78627b",
"path: /launcher/processes",
"path: /compute/contexts/8c3023b8-9fel-4b4b-ba67-7ced166e9b49/sessions",
"correlator: 09429966-83c0-41b2-6383-3d0b49672e7d;lle006aa-92e9-471c-blbd-bcbcff7cd9f1"
"errors":[
{
"errorCode": 10500,
"message": "The identifier values for USER \"sasboot\" were not found.",
"detail": [
"traceld: 504f36fa9c78627b",
"path: /identities/users/@currentUser/identifier"
]
"httpStatusCode": 404

What can be the solution to run the job using the client id authenticated by sasboot or are there any alternative 

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 273 views
  • 0 likes
  • 2 in conversation