~ubuntu-branches/ubuntu/natty/python-launchpadlib/natty-proposed

« back to all changes in this revision

Viewing changes to src/launchpadlib/credentials.py

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2010-03-23 21:21:00 UTC
  • mfrom: (1.1.8 upstream) (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100323212100-flkpdrt3ho3ezys9
Tags: 1.5.7-1
* New upstream release.
* Switch to format 3.0 (quilt).

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
            oauth_signature_method='PLAINTEXT',
93
93
            oauth_signature='&')
94
94
        url = web_root + request_token_page
95
 
        headers = {}
 
95
        headers = {'Referer' : web_root}
96
96
        if token_format == self.DICT_TOKEN_FORMAT:
97
97
            headers['Accept'] = 'application/json'
98
98
        response, content = httplib2.Http().request(
135
135
            oauth_token=self._request_token.key,
136
136
            oauth_signature='&%s' % self._request_token.secret)
137
137
        url = web_root + access_token_page
 
138
        headers = {'Referer' : web_root}
138
139
        response, content = httplib2.Http().request(
139
 
            url, method='POST', body=urlencode(params))
 
140
            url, method='POST', headers=headers, body=urlencode(params))
140
141
        if response.status != 200:
141
142
            raise HTTPError(response, content)
142
143
        self.access_token = AccessToken.from_string(content)
215
216
        # We can't use httplib2's add_credentials, because Launchpad
216
217
        # doesn't respond to credential-less access with a 401
217
218
        # response code.
218
 
        headers = {'Accept' : 'application/json'}
 
219
        headers = {'Accept' : 'application/json',
 
220
                   'Referer' : self.web_root}
219
221
        headers['Authorization'] = self._auth_header(username, password)
220
222
        response, content = self.http.request(url, headers=headers)
221
223
        # Detect common error conditions and set the response code
232
234
    def grant_access(self, username, password, request_token, access_level,
233
235
                     context=None):
234
236
        """Grant a level of access to an application on behalf of a user."""
235
 
        headers = {'Content-type' : 'application/x-www-form-urlencoded'}
 
237
        headers = {'Content-type' : 'application/x-www-form-urlencoded',
 
238
                   'Referer' : self.web_root}
236
239
        headers['Authorization'] = self._auth_header(username, password)
237
240
        body = "oauth_token=%s&field.actions.%s=True" % (
238
241
            quote(request_token), quote(access_level))