labpack/authentication/oauth2.py
def generate_url(self, service_scope=None, state_value='', additional_fields=None):

        ''' a method to generate an authorization url to oauth2 service for client

        :param service_scope: [optional] list with scope of permissions for agent
        :param state_value: [optional] string with unique identifier for callback
        :param additional_fields: [optional] dictionary with key value strings for service
        :return: string with authorization url
        '''

        title = '%s.generate_url' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'state_value': state_value,
            'service_scope': service_scope,
            'additional_fields': additional_fields
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)

    # validate additional fields
        if additional_fields:
            for key, value in additional_fields.items():
                if not isinstance(value, str):
                    raise TypeError("%s(additional_fields={'%s':'...'}) must be a string datatype." % (title, key))

    # construct query parameters
        query_params = {
            'response_type': 'code',
            'client_id': self.client_id,
            'redirect_uri': self.redirect_uri
        }
        if state_value:
            query_params['state'] = state_value
        if service_scope:
            for item in service_scope:
                if 'scope' not in query_params.keys():
                    query_params['scope'] = ''
                if query_params['scope']:
                    query_params['scope'] += ' '
                query_params['scope'] += item
        if additional_fields:
            query_params.update(**additional_fields)

    # encode query parameters
        from urllib.parse import urlencode
        url_string = '%s?%s' % (self.auth_endpoint, urlencode(query_params))

        return url_string
 a method to generate an authorization url to oauth2 service for client

        :param service_scope: [optional] list with scope of permissions for agent
        :param state_value: [optional] string with unique identifier for callback
        :param additional_fields: [optional] dictionary with key value strings for service
        :return: string with authorization url
        
a method to generate an authorization url to oauth2 service for client
a method to generate an authorization url to oauth2 service for client
def generate_url(self, service_scope=None, state_value='', additional_fields=None):
        title = '%s.generate_url' % self.__class__.__name__
        input_fields = {
            'state_value': state_value,
            'service_scope': service_scope,
            'additional_fields': additional_fields
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
        if additional_fields:
            for key, value in additional_fields.items():
                if not isinstance(value, str):
                    raise TypeError("%s(additional_fields={'%s':'...'}) must be a string datatype." % (title, key))
        query_params = {
            'response_type': 'code',
            'client_id': self.client_id,
            'redirect_uri': self.redirect_uri
        }
        if state_value:
            query_params['state'] = state_value
        if service_scope:
            for item in service_scope:
                if 'scope' not in query_params.keys():
                    query_params['scope'] = ''
                if query_params['scope']:
                    query_params['scope'] += ' '
                query_params['scope'] += item
        if additional_fields:
            query_params.update(**additional_fields)
        from urllib.parse import urlencode
        url_string = '%s?%s' % (self.auth_endpoint, urlencode(query_params))
        return url_string
def generate_url ( self , service_scope = None , state_value = '' , additional_fields = None ) : title = '%s.generate_url' % self . __class__ . __name__ input_fields = { 'state_value' : state_value , 'service_scope' : service_scope , 'additional_fields' : additional_fields } for key , value in input_fields . items ( ) : if value : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) if additional_fields : for key , value in additional_fields . items ( ) : if not isinstance ( value , str ) : raise TypeError ( "%s(additional_fields={'%s':'...'}) must be a string datatype." % ( title , key ) ) query_params = { 'response_type' : 'code' , 'client_id' : self . client_id , 'redirect_uri' : self . redirect_uri } if state_value : query_params [ 'state' ] = state_value if service_scope : for item in service_scope : if 'scope' not in query_params . keys ( ) : query_params [ 'scope' ] = '' if query_params [ 'scope' ] : query_params [ 'scope' ] += ' ' query_params [ 'scope' ] += item if additional_fields : query_params . update ( ** additional_fields ) from urllib . parse import urlencode url_string = '%s?%s' % ( self . auth_endpoint , urlencode ( query_params ) ) return url_string
a method to generate an authorization url to oauth2 service for client
a method to generate an authorization url to oauth2 service for client
''' a method to generate an authorization url to oauth2 service for client

        :param service_scope: [optional] list with scope of permissions for agent
        :param state_value: [optional] string with unique identifier for callback
        :param additional_fields: [optional] dictionary with key value strings for service
        :return: string with authorization url
        ''' # validate inputs
 # validate additional fields
 # construct query parameters
 # encode query parameters

string with authorization url
string with authorization url
self
service_scope
[optional] list with scope of permissions for agent
[ optional ] list with scope of permissions for agent
state_value
[optional] string with unique identifier for callback
[ optional ] string with unique identifier for callback
additional_fields
[optional] dictionary with key value strings for service
[ optional ] dictionary with key value strings for service