403 Access Denied When POST Request - python

I'm trying to post request to https://satreg-api.collegeboard.org/msregadmintestcenter-prod/student/search-test-center-admins and check seat available but keep getting 403 Forbidden error
Pls help me.

Looks like you some sort of a authentication token. The most known method is sending a Bearer-token via the headers. How to get the Token is up to you tho.

Related

Python - JIRAerror hhtp 403 url captcha challenge

Hi I am trying to connect to Jira python package JIRA
Here is command
j_url = 'https://myserver.com/jira'
JIRA(j_url, auth=(user, pass), max_retries=5)
I am getting the following error. I was not getting this error before. Only thing is changed, I did changed my password yesterday and it failed few times
JIRAError: JiraError HTTP 403 url: https://xxxxxxx/jira/rest/auth/1/session
text: CAPTCHA_CHALLENGE; login-url=xxxxxx/jira/login.jsp
Any idea what could be possible issue here?
It is solved now.
There is Current failed logins count in Jira profile. If it exceed certain threshold then API is failing. You need to get it reset by Admin

Rest api of gerrit gives the response but Python-gerrit-api package for fetching revisions gives status 404

Documentation: https://python-gerrit-api.readthedocs.io/en/latest/
Code
gerrit = GerritClient(base_url="https://gerrit.xx.com",username='xxx',password='xxx')
change = gerrit.changes.get("xxx")
ab=change.get_revision("32423")
print(ab.get_commit().list_change_files())
Question
For some endpoints, I am able to send get responses from the rest api but via this package I get this error(gerrit.utils.exceptions.NotFoundError: 404 Client Error). I am able to get response from Get Rest api for this url: gerrit.xx.xx.com/a/projects/xxxx/commits/xxxx/files via postman. But error with above code.
Looks like this is a bug, I have fixed it and made a pull request. See: https://github.com/shijl0925/python-gerrit-api/pull/5

Gmail API watch() not working properly

I am trying to run watch() on my inbox and send it to a pub/sub.
However, I keep getting this error:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/gmail/v1/users/me.com/watch?alt=json returned "Invalid topicName does not match projects/western-oarlock/topics/*">
The code I am sending is:
request = {
'labelIds': ['INBOX'],
'topicName': 'projects/flask-app/topics/myTopic'
}
service.users().watch(userId='me', body=request).execute()
Why is it attempting to contact western-oarlock instead of flask-app?
Check if access token you are using is the right one.
Check if .p12 key you are using is from the same project, or try using a new key.
I had the same problem, in my case the cause was access token I used in Google Cloud API OAuth2 authentication which was generated using wrong service account. Hovewer I've read then somewehere on the Internet that wrong .p12 key also can cause this issue.
It ended up having to do with the JSON Secrets file. I was authenticating on the wrong project.

Missing OAuth request token cookie error using tornado and TwitterMixin

I'm using tornado and the TwitterMixin and I use the following basic code:
class OauthTwitterHandler(BaseHandler, tornado.auth.TwitterMixin):
#tornado.web.asynchronous
def get(self):
if self.get_argument("oauth_token", None):
self.get_authenticated_user(self.async_callback(self._on_auth))
return
self.authorize_redirect()
def _on_auth(self, user):
if not user:
raise tornado.web.HTTPError(500, "Twitter auth failed")
self.write(user)
self.finish()
For me it works very well but sometimes, users of my application get a 500 error which says:
Missing OAuth request token cookie
I don't know if it comes from the browser or the twitter api callback configuration.
I've looked through the tornado code and I don't understand why this error
appears.
Two reasons why this might happen:
Some users may have cookies turned off, in which case this won't work.
The cookie hasn't authenticated. It's possible that the oauth_token argument is set, but the cookie is not. Not sure why this would happen, you'd have to log some logging to understand why.
At any rate, this isn't an "error," but rather a sign the user isn't authenticated. Maybe if you see that you should just redirect them to the authorize URL and let them try again.
I found the solution !!
It was due to my DNS.
I didn't put the redirection for www.mydomain.com and mydomain.com so sometimes the cookie was set in www. and sometimes not then my server didn't check in the good place, didn't find the cookie and then send me a 500 error.
The reason this was happening to me is that the Callback URL configuration was pointing to a different domain.
Take a look at the settings tab for your application at https://dev.twitter.com/apps/ or if the users getting the error are accessing your site from a different domain.
See: http://groups.google.com/group/python-tornado/browse_thread/thread/55aa42eef42fa1ac

How do I know what's the realm and uri of a site

I want to use python's urllib2 with authentication and I need the realm and uri of a url. How do I get it?
thanks
When you make a request for a resource that requires authentication, the server will respond with a 401 status code, and a header that contains the realm:
WWW-Authenticate: Basic realm="the realm"
The URI is the URL you're trying to access.

Categories