Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unauthorized access #106

Open
rohitjangid96 opened this issue Mar 29, 2019 · 19 comments
Open

Unauthorized access #106

rohitjangid96 opened this issue Mar 29, 2019 · 19 comments

Comments

@rohitjangid96
Copy link

import pysnow

# Create client object
c = pysnow.Client(instance='********', user='*******', password='*********')

# Define a resource, here we'll use the incident table API
incident = c.resource(api_path='/table/incident')

# Query for incident with number INC012345
response = incident.get(query={'number': 'INC0683731'})

# Print out the matching record
print(response.one())

raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://cablevision.service-now.com/api/now/table/incident?sysparm_query=number%3DINC0683731&sysparm_limit=10000&sysparm_offset=0&sysparm_display_value=False&sysparm_suppress_pagination_header=False&sysparm_exclude_reference_link=False&sysparm_view=&sysparm_fields=

@rbw
Copy link
Owner

rbw commented Mar 29, 2019

Hello,

This means you're trying to authenticate with incorrect credentials.

@rbw rbw closed this as completed Mar 29, 2019
@marirs
Copy link

marirs commented Jul 11, 2019

Hi - I'm accessing with correct creds, & I'm facing the 401 issue. If I paste that url in chrome, I get the results. But via pysnow, its a 401

@rbw
Copy link
Owner

rbw commented Jul 11, 2019

Hmm.. strange. Which version of ServiceNow are you connecting to? Also, are you able to reproduce this if connecting to a "demo" instance?

@rbw
Copy link
Owner

rbw commented Jul 11, 2019

Also, if you're using an older version of ServiceNow you'll need to enable the REST plugin.

@marirs
Copy link

marirs commented Jul 11, 2019

I guess the latest version of SNOW. Where can I find the version?
How can get to a demo instance?
Sorry of asking the above questions; I'm new to SNOW and trying to write scripts to fetch data

@rbw
Copy link
Owner

rbw commented Jul 11, 2019

Check out https://developer.servicenow.com -- you'll need to create an account.

@marirs
Copy link

marirs commented Jul 11, 2019

Build name: Kingston
Build date: 04-22-2019_1559

@marirs
Copy link

marirs commented Jul 11, 2019

Yeah - It seems to work on the demo server... what could I be missing on the prod

@rbw
Copy link
Owner

rbw commented Jul 11, 2019

Not sure. I'd check the logs.

Here's one guide:
https://docs.servicenow.com/integrate/inbound_rest/reference/r_DebuggingRESTQueries.html

@marirs
Copy link

marirs commented Jul 12, 2019

It works when I paste the url in browser, but not via script. anything to do with SSO?
python script to the url using basic auth works..

@marirs
Copy link

marirs commented Jul 12, 2019

So its the problem with SSO. Need to handle SSO auth differently.
Thanks and will close this

@rbw
Copy link
Owner

rbw commented Jul 12, 2019

👍

Np

@marirs
Copy link

marirs commented Jul 14, 2019

Hi - Just want to check - how can I get the work notes and comments as well?
In the SNOW docs, it says I need to query the sys_journal table with the sys_id like this:
sysparm_query=element_id=d71f7935c0a8016700802b64c67c11c6

eg: https://community.servicenow.com/community?id=community_question&sys_id=da94cba9dbd8dbc01dcaf3231f961921

How can I do this in pysnow. checked docs, etc.. not able to find any way to do this..

@rbw
Copy link
Owner

rbw commented Jul 14, 2019

Check out #112

@marirs
Copy link

marirs commented Jul 15, 2019

your awesome :)

@reddevil311
Copy link

So its the problem with SSO. Need to handle SSO auth differently.
Thanks and will close this

Hello Marirs,

Did you figure out how to solve the SSO connectivity issue with service now? There was no response posted here if it was resolved so just wanted to know. I am running into a similar issue and haven't been able to find a response anywhere to resolve this.

@michaelculhane
Copy link

michaelculhane commented Jul 11, 2020

So its the problem with SSO. Need to handle SSO auth differently.
Thanks and will close this

Hello Marirs,

Did you figure out how to solve the SSO connectivity issue with service now? There was no response posted here if it was resolved so just wanted to know. I am running into a similar issue and haven't been able to find a response anywhere to resolve this.

I'm getting the same error 401 Client Error: Unauthorized for url.

Works fine if I use requests module instead of pysnow

@rbw rbw reopened this Jul 11, 2020
@reddevil311
Copy link

I have tried using pysnow and servicenow but I run into same issue with both. Haven't been able to figure out a way to get past the 401 error for SSO login. It work's perfectly fine for non SSO connections. Not sure if anyone has found a way around it yet.

@Maarc-D
Copy link

Maarc-D commented Jan 14, 2021

I have tried using pysnow and servicenow but I run into same issue with both. Haven't been able to figure out a way to get past the 401 error for SSO login. It work's perfectly fine for non SSO connections. Not sure if anyone has found a way around it yet.

I think you must use OAuth token generated using your servicenow portal directly (if you have enought right to do it) if you are using an SSO. ans using the pysnow.OAuthClient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants