{"action":"opened","issue":{"url":"https://api.github.com/repos/requests/requests-oauthlib/issues/211","labels_url":"https://api.github.com/repos/requests/requests-oauthlib/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/requests/requests-oauthlib/issues/211/comments","events_url":"https://api.github.com/repos/requests/requests-oauthlib/issues/211/events","html_url":"https://github.com/requests/requests-oauthlib/issues/211","id":122485928,"number":211,"title":"Wrong Authorization header?","user":{"login":"chaosct","id":184808,"avatar_url":"https://avatars.githubusercontent.com/u/184808?v=3","gravatar_id":"","url":"https://api.github.com/users/chaosct","html_url":"https://github.com/chaosct","followers_url":"https://api.github.com/users/chaosct/followers","following_url":"https://api.github.com/users/chaosct/following{/other_user}","gists_url":"https://api.github.com/users/chaosct/gists{/gist_id}","starred_url":"https://api.github.com/users/chaosct/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaosct/subscriptions","organizations_url":"https://api.github.com/users/chaosct/orgs","repos_url":"https://api.github.com/users/chaosct/repos","events_url":"https://api.github.com/users/chaosct/events{/privacy}","received_events_url":"https://api.github.com/users/chaosct/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-16T11:43:11Z","updated_at":"2015-12-16T11:43:11Z","closed_at":null,"body":"I'm having trouble using requests-oauthlib against a flask-oauthlib provider. I'm using the [reference implementation of flask-oauthlib provider](https://github.com/lepture/example-oauth2-server/) and while using the same library for the client works, using requests-oauthlib fails.\r\n\r\nWhat I do is:\r\n```\r\nclient_id = 'AHc6492FZUnD6l9kAENvU8rM8AQyEZAOYnLf2JEi'\r\nclient_secret = 'NJWNqoG5wh2QQ3aCobnmaHNzcNBRozL60p7S8zGcHwXWOYNEdN'\r\nredirect_uri = 'http://127.0.0.1:8000/authorized'\r\nauthorization_base_url = 'http://127.0.0.1:5000/oauth/authorize'\r\ntoken_url = \"http://127.0.0.1:5000/oauth/token\"\r\nscope = ['email']\r\nfrom requests_oauthlib import OAuth2Session\r\nprovider = OAuth2Session(client_id,scope=scope,redirect_uri=redirect_uri)\r\nauthorization_url, state = provider.authorization_url(authorization_base_url)\r\nprint(\"GO TO: \"+authorization_url)\r\n\r\n#this prints the auth url:\r\nGO TO: http://127.0.0.1:5000/oauth/authorize?response_type=code&client_id=AHc6492FZUnD6l9kAENvU8rM8AQyEZAOYnLf2JEi&redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2Fauthorized&scope=email&state=vgta4Exp0v4dPiJdspfIlXOeTgvN3Q\r\n\r\n# I go there and authorize the client. I get to go to a redirected url, that I paste here:\r\nurl = \"http://127.0.0.1:8000/authorized?state=vgta4Exp0v4dPiJdspfIlXOeTgvN3Q&code=r6s8qAAYqJzffFi3iaKl02KgSTT20I\"\r\nprovider.fetch_token(token_url, client_secret=client_secret, authorization_response=url)\r\n```\r\n\r\nThis last line raises a `InvalidClientError` exception.\r\n\r\n```\r\nInvalidClientError                        Traceback (most recent call last)\r\n<ipython-input-7-5ff386dbf014> in <module>()\r\n      1 url = \"http://127.0.0.1:8000/authorized?state=vgta4Exp0v4dPiJdspfIlXOeTgvN3Q&code=r6s8qAAYqJzffFi3iaKl02KgSTT20I\"\r\n----> 2 repovizz.fetch_token(token_url, client_secret=client_secret, authorization_response=url)\r\n\r\n/home/carles/tmp/example-oauth2-server/local/lib/python2.7/site-packages/requests_oauthlib/oauth2_session.pyc in fetch_token(self, token_url, code, authorization_response, body, auth, username, password, method, timeout, headers, verify, **kwargs)\r\n    230             r = hook(r)\r\n    231 \r\n--> 232         self._client.parse_request_body_response(r.text, scope=self.scope)\r\n    233         self.token = self._client.token\r\n    234         log.debug('Obtained token %s.', self.token)\r\n\r\n/home/carles/tmp/example-oauth2-server/local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.pyc in parse_request_body_response(self, body, scope, **kwargs)\r\n    407         .. _`Section 7.1`: http://tools.ietf.org/html/rfc6749#section-7.1\r\n    408         \"\"\"\r\n--> 409         self.token = parse_token_response(body, scope=scope)\r\n    410         self._populate_attributes(self.token)\r\n    411         return self.token\r\n\r\n/home/carles/tmp/example-oauth2-server/local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.pyc in parse_token_response(body, scope)\r\n    374 \r\n    375     params = OAuth2Token(params, old_scope=scope)\r\n--> 376     validate_token_parameters(params)\r\n    377     return params\r\n    378 \r\n\r\n/home/carles/tmp/example-oauth2-server/local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.pyc in validate_token_parameters(params)\r\n    381     \"\"\"Ensures token precence, token type, expiration and scope in params.\"\"\"\r\n    382     if 'error' in params:\r\n--> 383         raise_from_error(params.get('error'), params)\r\n    384 \r\n    385     if not 'access_token' in params:\r\n\r\n/home/carles/tmp/example-oauth2-server/local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/errors.pyc in raise_from_error(error, params)\r\n    269     for _, cls in inspect.getmembers(sys.modules[__name__], inspect.isclass):\r\n    270         if cls.error == error:\r\n--> 271             raise cls(**kwargs)\r\n\r\nInvalidClientError: (invalid_client) \r\n```\r\n\r\nIt seems that in the header is passed like this: `u\\'Authorization\\': u\\'Basic Tm9uZTpOb25l\\'`, which is used by flask-oauthlib to retrieve the client id and secret, by deserializing this using base64 encoding, which results in `\"None:None\"`. This triggers the HTTP 401 client error response.\r\n\r\nAm I doing something wrong here? It seems that requests-oauthib is creating faulty headers, but I am no expert in oauthlib2 and that may be also a wrong/restricted impolementation of flask-oauthlib...\r\n\r\nVersions:\r\n```\r\nrequests-oauthlib==0.6.0\r\nFlask-OAuthlib==0.9.2\r\n```"}}