def get_auth_uri(auth_service, client_id, scope, redirect_uri, response_type,
                 state, access_type, approval_prompt):
  """Generates an authorization uri."""
  errors = []
  if response_type not in VALID_RESPONSE_TYPES:
    errors.append(
        '{0} is not a valid response_type, must be {1}.'.format(
        response_type, VALID_RESPONSE_TYPES))
  if not client_id:
    errors.append('client_id is missing or empty.')
  if not redirect_uri:
    errors.append('redirect_uri is missing or empty.')
  if not scope:
    errors.append('scope is missing or empty.')
  if access_type not in VALID_ACCESS_TYPES:
    errors.append('access_type is invalid.')
  if approval_prompt not in VALID_APPROVAL_PROMPTS:
    errors.append('approval_prompt is invalid')
  if errors:
    raise ValueError('Invalid parameters: {0}'.format('\n'.join(errors)))
  params = {
      'response_type': response_type,
      'client_id': client_id,
      'redirect_uri': redirect_uri,
      'scope': scope,
      'access_type': access_type,
      'approval_prompt': approval_prompt,
      'state': state,
  }
  return '?'.join([auth_service, urllib.urlencode(params)])
def get_auth_uri ( auth_service , client_id , scope , redirect_uri , response_type , state , access_type , approval_prompt ) : errors = [ ] if response_type not in VALID_RESPONSE_TYPES : errors . append ( '{0} is not a valid response_type, must be {1}.' . format ( response_type , VALID_RESPONSE_TYPES ) ) if not client_id : errors . append ( 'client_id is missing or empty.' ) if not redirect_uri : errors . append ( 'redirect_uri is missing or empty.' ) if not scope : errors . append ( 'scope is missing or empty.' ) if access_type not in VALID_ACCESS_TYPES : errors . append ( 'access_type is invalid.' ) if approval_prompt not in VALID_APPROVAL_PROMPTS : errors . append ( 'approval_prompt is invalid' ) if errors : raise ValueError ( 'Invalid parameters: {0}' . format ( '\n' . join ( errors ) ) ) params = { 'response_type' : response_type , 'client_id' : client_id , 'redirect_uri' : redirect_uri , 'scope' : scope , 'access_type' : access_type , 'approval_prompt' : approval_prompt , 'state' : state , } return '?' . join ( [ auth_service , urllib . urlencode ( params ) ] )
Generates an authorization uri.