예제 #1
0
  def test_tokens(self):
    request_request = oauth.OAuthRequest.from_consumer_and_token(
        self.desktop_consumer,
        http_url="http://%s/api/request_token" % settings.DOMAIN,
        )
    request_request.sign_request(self.sig_hmac, self.desktop_consumer, None)
    response = self.client.get("/api/request_token", request_request.parameters)

    request_token = oauth.OAuthToken.from_string(response.content)

    # cheat and authorize this token using the backend
    api.oauth_authorize_request_token(api.ROOT, 
                                      request_token.key,
                                      actor='*****@*****.**', 
                                      perms="read")

    access_request = oauth.OAuthRequest.from_consumer_and_token(
        self.desktop_consumer,
        request_token,
        http_url="http://%s/api/access_token" % (settings.DOMAIN),
        )
    access_request.sign_request(self.sig_hmac, self.desktop_consumer,
                                request_token)

    response = self.client.get("/api/access_token", access_request.parameters)

    access_token = oauth.OAuthToken.from_string(response.content)