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

Content-Type header not recognized in vsc.utils.rest_oauth #62

Open
backelj opened this issue Aug 8, 2019 · 6 comments
Open

Content-Type header not recognized in vsc.utils.rest_oauth #62

backelj opened this issue Aug 8, 2019 · 6 comments

Comments

@backelj
Copy link

backelj commented Aug 8, 2019

Hi,

I was checking the function request_access_token from vsc.utils.rest_oauth, but it fails to work because of the line:

request.add_header('Content-Type', 'application/json')

It looks like this has to be written without the hyphen:

request.add_header('ContentType', 'application/json')

Can someone confirm this?

-- Thanks,

Franky

@wpoely86
Copy link
Contributor

wpoely86 commented Aug 8, 2019

That seems odd. It should have a hyphen: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type

@backelj
Copy link
Author

backelj commented Aug 8, 2019

@wpoely86 You're right, but the code as it is now, does not seem to work. But that's probably due to some other issue (which I haven't found just yet). In fact, commenting out that one line in request_access_token makes it work again.

@stdweird
Copy link
Member

stdweird commented Aug 8, 2019

@backelj where do you get an error?

@wpoely86
Copy link
Contributor

wpoely86 commented Aug 8, 2019

This request_access_token should probably be moved to vsc-accountpage-clients. It looks like something from long ago?

@backelj
Copy link
Author

backelj commented Aug 8, 2019

@stdweird I was just calling request_access_token from a test script... The error I get is:

File "[...]/vsc/utils/rest_oauth.py", line 45, in request_access_token
uri = opener.open(request)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request

As said, commenting out the Content-Type line in request_access_token makes it work.

@stdweird
Copy link
Member

stdweird commented Aug 8, 2019

ok, looks like an error. afaik, we always use curl to fetch a new token and do not specify the content type, so i guess the json content type is not supported with this url. feel free to make a PR to remove the line

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

3 participants