Exemple #1
0
    def get_success_redirect(self):
        """
        :return: string with URL where the client should be redirected to
        """
        redirect_uri = self.attrs['redirect_uri']
        state = self.attrs.get('state')

        args = [('code', self.id), ]
        if state:
            args.append(('state', state), )

        return add_arguments(redirect_uri, args)
Exemple #2
0
    def get_error_redirect(self, error='access_denied'):
        """
        Construct and return URL with error message.

        :param error: error message to return
        :return: complete error URL, containing among others correct state
                 parameter.
        """
        redirect_uri = self.attrs['redirect_uri']
        state = self.attrs.get('state')
        args = [('error', error), ]
        if state:
            args.append(('state', state), )
        return add_arguments(redirect_uri, args)
Exemple #3
0
    def get_redirect(self, error=None):
        """
        Return redirect, as described in :rfc:`6749#4.1.2`

        If there is an code object, then proxy method invocation there.

        In no code defined (because request is invalid and you want to respond
        immediately), then return error response by itself

        :param error: string with error
        :return: string containing fully composed absolute URL which user
                 should be redirected to
        """
        error = error or self.error
        if self.code:
            return self.code.get_redirect(error=error)
        if not error:
            raise OauthistRuntimeError('No error defined, and no code saved. What'
                                       'redirect do you want to return?')
        args = [('error', error), ]
        if self.state:
            args.append(('state', self.state), )
        return add_arguments(self.redirect_uri, args)