sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
367 stars 149 forks source link

SAS Viya authentication error 401 #500

Closed andysas closed 1 year ago

andysas commented 1 year ago

I am trying to connect to a SAS Viya instance by using SASPy and I am getting the following authentication error.

SASHTTPauthenticateError: Failure in GET AuthToken. Failure in GET AuthToken. Status=401 Response=b'{"error":"unauthorized","error_description":"Bad credentials"}'

I am using httpsviya configuration and it has the following entry in the config file:

httpsviya = {'url' : 'https://sasserver.demo.sas.com', 'context' : 'Data Mining compute context', 'authkey' : 'viya_user-pw', 'options' : ["fullstimer", "memsize=1G"] }

Do let me know if there is some issue in my configuration. I am able to login normally to the url using my User ID/Password. And I am using an OS level ID(the SWAT connection is working for me with the same credentials).

Any inputs will help.

tomweber-sas commented 1 year ago

Well, the good news is that it looks like you're actually connecting to the viya instance. So the config seems good. Viya can be configured with a number of different authentication schemes, and SASPy supports them all; see this doc

I don't know how your deployment is configured for authentication, and if they have CAS configured to allow you to use the binary interface (instead of the http) then it requires host level credentials, while nothing else in viya uses that. The rest of viya uses different credentials and/or multi factor authentication, ...

Can you log on to SAS/Studio? Whatever credentials work for that, would also then work with SASPy. Given your url, try logging on to studio and see if you can tell what credentials it wants: https://sasserver.demo.sas.com/SASStudio

I expect you get the same failure if you use the credentials you're trying w/ saspy, in your authkey.

Let me know what you find, Tom

tomweber-sas commented 1 year ago

Can you tell me what versions of Viya and SASPy you're using? That may be helpful too.

tomweber-sas commented 1 year ago

Hey, I'm going to be out of the office till basically Jan 2nd. But I'll try to continue helping out on this as I can.

Thanks, Tom

andysas commented 1 year ago

Thanks for the prompt revert Tom. My Viya version is V.03.05 and my SASPy version is 4.4.1. The above url is not working for my credentials "https://sasserver.demo.sas.com/SASStudio" I am getting the following weird error: "The application could not log on to the server "localhost:8591". No server is available at that port on that machine."

tomweber-sas commented 1 year ago

Viya 3.5. the HTTP access method can't be used for that. In 3.5 there's no API provided, neither IOM not HTTP So the only way to connect is with STDIO over SSH.

tomweber-sas commented 1 year ago

Though, my doc does say http with 3.5 if the compute service has been configured. So, can you check with your admin about this? Sorry, I can't access anything currently, just on my phone and traveling.

tomweber-sas commented 1 year ago

Finally got to where I have wifi. Sorry, been up since 3am and been traveling all day. Viya 3.3 and 3.4 didn't have the compute API. 3.5 was the first, thought it may may not be configured by default. If all that is set up and should be working, there is one other possibility I can think of at the moment. I had to make a change for viya 4, which is what we've been working on for the past 3 years, due to changes in the authorization. It's possible that could be the problem. I can't test it out but if you could try saspy version 4.3.5, that is before that change. If that version works, then I'll see about fixing that. If it doesn't work, then that's not the problem.

Thank, and sorry for the confusion, Tom

andysas commented 1 year ago

Hi Tom It worked with 4.3.5. Thanks a lot for the quick reply and for replying during your holidays.

Regards Anindo

tomweber-sas commented 1 year ago

Thanks @andysas, I believe I caused that regression with a rework of the authentication code based upon viya 4 changes I had to accommodate. I'll test out and push a fix for that today, I hope. If so, I'll build a new release and then you can get the latest and be back in business. I'll post back when done!

Thanks, Tom

tomweber-sas commented 1 year ago

I've fixed this and pushed the code to main. Before creating a new release, could you possibly pull from main and test it out with your specific case? I want to be sure it works for your use case, like it works for me with the case I tried, before building the new release. If not, I can still go ahead; I saw the problem and verified the fix, but I like to be sure it solves yours too, in case there's something different. You can install main via: pip install git+https://git@github.com/sassoftware/saspy.git

Thanks, Tom

tomweber-sas commented 1 year ago

tell you what, I've gone ahead and published a new release, this is here, V4.2.2, and on PyPI, and Conda (w/in the next 24 hours as their bots build the new version). If it somehow doesn't fix your case I'll resolve that, but I'm pretty sure I have the problem fixed. Just pull the new release itself and give it a try:

pip uninstall -y saspy pip install saspy

SAS is closed until the new year, so I wanted to just build this for real and let you get it as production. Let me know either way, and we can address it. I'll try to check this next week when I can, and see if there's any issue, or it's fixed and working for you (that's what I expect).

Have a great holiday! Tom

tomweber-sas commented 1 year ago

V4.4.3 that is

andysas commented 1 year ago

Hi Tom The new version of SASPy is working for me. Thanks a lot for working through your vacation and addressing this issue for me.

tomweber-sas commented 1 year ago

No problem! Glad you're back up running. I'll go ahead and close this one out. Let me know if you need anything else! Happy new year! Tom