BookmarkSubscribeRSS Feed
smallajyosula
Calcite | Level 5

Hi,

 

I am developing a ASP.Net webforms application using .Net Framework 4.5.2 and C#. I have a web page where a list of SAS reports are displayed. I was provided a access token to access the SAS Viya. How can I pass the the token to the report. Below is the sample report. There might be several other reports like below. I want to avoid the SAS Logon page and open the report. Since I need to use interactive UI, I cannot use the SAS REST API.

 

https://sasviya.test.com/SASJobExecution/?_program=/Projects/MyOrg/ExpenseReport

 

Any suggestions are welcome.

4 REPLIES 4
DavidHD
SAS Employee

Hi @smallajyosula ,

 

You pass the token in the header of your Request:

Authorization: 'Bearer <your-token>'

 

Please be advised that by default Accept-Tokens in Viya have a validity of 12 hours so you will either implement a token refresh or have your Viya admins issue a token that has a longer lifetime.

 

I'm no C# programmer but it should look a little something like this:

var client = new RestClient("https://sasviya.test.com/SASJobExecution/?_program=/Projects/MyOrg/ExpenseReport");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <your-token>");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

Cheers,

David

 

 

smallajyosula
Calcite | Level 5
Hi David,

The solution which you provided works fine for REST API calls but not for interactive SAS Report GUI. I want my user to click on a link on our website and the SAS Viya report should open without asking for SAS Logon screen. Once the SAS Report opens up the user should be able to select various input parameters and get the report. Then it is up to the user to whether download, print or email the report output.
DavidHD
SAS Employee

Oh okay, I'm sorry I guess I miss understood the use case. Going around the login of SAS Viya is of course dangerous because then the link can be shared with anyone in your organization and they can open up the report and if there is row level security on the table this gets even worse.

 

Just a reminder I'm sure you know what you are sharing with the users. You have to ensure that Guest Access is enabled for your SAS environment, then Copy Link of the VA report you want to be accessible through your application and enable guest access (see Screenshot). Clicking on that link should open the report directly without a login.

 

DavidHD_0-1627570050038.png

 

smallajyosula
Calcite | Level 5
Hi David,

I still want the report to be protected. So if I can pass the token through the QueryString to the report it should recognize and open the report. If no token is passed through the QueryString then it should redirect to the SAS Logon screen. So my main purpose is the user clicks on a link on our internal website and then the report should open. So just to clarify that all these are internal reports hosted on SAS Viya which is not accessible through public. My ultimate goal is to create a session for SAS Viya behind the scenes and open the report.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Discussion stats
  • 4 replies
  • 1165 views
  • 0 likes
  • 2 in conversation