Beispiel #1
0
    def _add_bearer_token(self, uri, http_method=u'GET', body=None,
            headers=None, token_placement=AUTH_HEADER):
        """Add a bearer token to the request uri, body or authorization header."""
        if token_placement == AUTH_HEADER:
            headers = prepare_bearer_headers(self.token, headers)

        if token_placement == URI_QUERY:
            uri = prepare_bearer_uri(self.token, uri)

        if token_placement == BODY:
            body = prepare_bearer_body(self.token, body)

        return uri, headers, body
Beispiel #2
0
    def _add_bearer_token(self, uri, http_method=u'GET', body=None,
            headers=None, token_placement=None):
        """Add a bearer token to the request uri, body or authorization header."""
        if token_placement == AUTH_HEADER:
            headers = prepare_bearer_headers(self.access_token, headers)

        elif token_placement == URI_QUERY:
            uri = prepare_bearer_uri(self.access_token, uri)

        elif token_placement == BODY:
            body = prepare_bearer_body(self.access_token, body)

        else:
            raise ValueError("Invalid token placement.")
        return uri, headers, body
Beispiel #3
0
    def _add_bearer_token(self,
                          uri,
                          http_method=u'GET',
                          body=None,
                          headers=None,
                          token_placement=AUTH_HEADER):
        """Add a bearer token to the request uri, body or authorization header."""
        if token_placement == AUTH_HEADER:
            headers = prepare_bearer_headers(self.token, headers)

        if token_placement == URI_QUERY:
            uri = prepare_bearer_uri(self.token, uri)

        if token_placement == BODY:
            body = prepare_bearer_body(self.token, body)

        return uri, headers, body