def get_authorize_url(self, redirect_uri=None, display='default'): """ return the authroize url that should be redirect """ redirect = redirect_uri if redirect_uri else self.redirect_uri if not redirect: raise WeiboAPIError('21305', 'Parameter absent: redirect_uri', 'OAuth2 request') kwargs = dict(client_id=self.client_id, response_type='code', display=display, redirect_uri=redirect) encoded_params, _ = encode_params('GET', **kwargs) print encoded_params return '%s%s?%s' % (self.auth_url, 'authorize', encoded_params)
def get_authorize_url(self, redirect_uri=None, display=None, response_type='code', endpoint='authorize', scopes=[], state=None): """ return the authroize url that should be redirect """ redirect = redirect_uri if redirect_uri else self.redirect_uri if not redirect: raise SSOBaseException('Redirect uri is needed.') state = state if state is not None else 'default_state' kwargs = dict(client_id=self.app_id, response_type=response_type, redirect_uri=redirect, scope=','.join(scopes), state=state) if display: kwargs.update(display=display) encoded_params, _ = encode_params('GET', **kwargs) return '%s%s?%s' % (self.auth_url, endpoint, encoded_params)