requests.api.request.build_absolute_uri

Here are the examples of the python api requests.api.request.build_absolute_uri taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

12 Examples 7

Example 1

Project: django-connected
Source File: base.py
View license
    def get_request_token(self, request, callback):
        """Fetch the OAuth request token. Only required for OAuth 1.0."""
        callback = force_text(request.build_absolute_uri(callback))
        try:
            response = self.request('post', self.request_token_url, oauth_callback=callback)
            response.raise_for_status()
        except RequestException as e:
            logger.error('Unable to fetch request token: {0}'.format(e))
            return None
        else:
            return response.text

Example 2

Project: django-connected
Source File: base.py
View license
    def get_redirect_args(self, request, callback):
        """Get request parameters for redirect url."""
        callback = force_text(request.build_absolute_uri(callback))
        raw_token = self.get_request_token(request, callback)
        token, secret, _ = self.parse_raw_token(raw_token)
        if token is not None and secret is not None:
            request.session[self.session_key] = raw_token
        args = {
            'oauth_token': token,
            'oauth_callback': callback,
        }

        scope = self.get_scope(request)
        if scope:
            args['scope'] = self.scope_separator.join(self.get_scope(request))

        return args

Example 3

Project: django-connected
Source File: base.py
View license
    def get_request_token(self, request, callback):
        """Fetch the OAuth request token. Only required for OAuth 1.0."""
        callback = force_text(request.build_absolute_uri(callback))
        try:
            response = self.request('post', self.request_token_url, oauth_callback=callback)
            response.raise_for_status()
        except RequestException as e:
            logger.error('Unable to fetch request token: {0}'.format(e))
            return None
        else:
            return response.text

Example 4

Project: django-connected
Source File: base.py
View license
    def get_redirect_args(self, request, callback):
        """Get request parameters for redirect url."""
        callback = force_text(request.build_absolute_uri(callback))
        raw_token = self.get_request_token(request, callback)
        token, secret, _ = self.parse_raw_token(raw_token)
        if token is not None and secret is not None:
            request.session[self.session_key] = raw_token
        args = {
            'oauth_token': token,
            'oauth_callback': callback,
        }

        scope = self.get_scope(request)
        if scope:
            args['scope'] = self.scope_separator.join(self.get_scope(request))

        return args

Example 5

Project: django-all-access
Source File: clients.py
View license
    def get_request_token(self, request, callback):
        "Fetch the OAuth request token. Only required for OAuth 1.0."
        callback = force_text(request.build_absolute_uri(callback))
        try:
            response = self.request(
                'post', self.provider.request_token_url, oauth_callback=callback)
            response.raise_for_status()
        except RequestException as e:
            logger.error('Unable to fetch request token: {0}'.format(e))
            return None
        else:
            return response.text

Example 6

Project: django-all-access
Source File: clients.py
View license
    def get_request_token(self, request, callback):
        "Fetch the OAuth request token. Only required for OAuth 1.0."
        callback = force_text(request.build_absolute_uri(callback))
        try:
            response = self.request(
                'post', self.provider.request_token_url, oauth_callback=callback)
            response.raise_for_status()
        except RequestException as e:
            logger.error('Unable to fetch request token: {0}'.format(e))
            return None
        else:
            return response.text

Example 7

Project: django-all-access
Source File: clients.py
View license
    def get_redirect_args(self, request, callback):
        "Get request parameters for redirect url."
        callback = force_text(request.build_absolute_uri(callback))
        raw_token = self.get_request_token(request, callback)
        token, secret = self.parse_raw_token(raw_token)
        if token is not None and secret is not None:
            request.session[self.session_key] = raw_token
        return {
            'oauth_token': token,
            'oauth_callback': callback,
        }

Example 8

Project: django-all-access
Source File: clients.py
View license
    def get_redirect_args(self, request, callback):
        "Get request parameters for redirect url."
        callback = force_text(request.build_absolute_uri(callback))
        raw_token = self.get_request_token(request, callback)
        token, secret = self.parse_raw_token(raw_token)
        if token is not None and secret is not None:
            request.session[self.session_key] = raw_token
        return {
            'oauth_token': token,
            'oauth_callback': callback,
        }

Example 9

Project: django-all-access
Source File: clients.py
View license
    def get_redirect_args(self, request, callback):
        "Get request parameters for redirect url."
        callback = request.build_absolute_uri(callback)
        args = {
            'client_id': self.provider.consumer_key,
            'redirect_uri': callback,
            'response_type': 'code',
        }
        state = self.get_application_state(request, callback)
        if state is not None:
            args['state'] = state
            request.session[self.session_key] = state
        return args

Example 10

Project: django-all-access
Source File: clients.py
View license
    def get_redirect_args(self, request, callback):
        "Get request parameters for redirect url."
        callback = request.build_absolute_uri(callback)
        args = {
            'client_id': self.provider.consumer_key,
            'redirect_uri': callback,
            'response_type': 'code',
        }
        state = self.get_application_state(request, callback)
        if state is not None:
            args['state'] = state
            request.session[self.session_key] = state
        return args

Example 11

Project: django-connected
Source File: base.py
View license
    def get_redirect_args(self, request, callback):
        """Get request parameters for redirect url."""
        callback = request.build_absolute_uri(callback)
        args = {
            'client_id': self.consumer_key,
            'redirect_uri': callback,
            'response_type': 'code',
        }

        scope = self.get_scope(request)
        if scope:
            args['scope'] = self.scope_separator.join(self.get_scope(request))

        state = self.get_application_state(request, callback)
        if state is not None:
            args['state'] = state
            request.session[self.session_key] = state

        auth_params = self.get_auth_params(request)
        if auth_params:
            args.update(auth_params)

        return args

Example 12

Project: django-connected
Source File: base.py
View license
    def get_redirect_args(self, request, callback):
        """Get request parameters for redirect url."""
        callback = request.build_absolute_uri(callback)
        args = {
            'client_id': self.consumer_key,
            'redirect_uri': callback,
            'response_type': 'code',
        }

        scope = self.get_scope(request)
        if scope:
            args['scope'] = self.scope_separator.join(self.get_scope(request))

        state = self.get_application_state(request, callback)
        if state is not None:
            args['state'] = state
            request.session[self.session_key] = state

        auth_params = self.get_auth_params(request)
        if auth_params:
            args.update(auth_params)

        return args