def get(self): client_id = self.get_argument('client_id', '') client_secret = self.get_argument('client_secret', '') redirect_uri = self.get_argument('redirect_uri', '') grant_type = self.get_argument('grant_type', '') code = self.get_argument('code', '') user_id = self.current_user_id if grant_type == 'authorization_code': if oauth_authorization_code_verify(code): authorization_id = oauth_authorization_code_verify(code) if oauth_secret_verify(client_id, client_secret): if oauth_client_uri.get(client_id) == redirect_uri: id, access_token = oauth_access_token_new(client_id, user_id) refresh_token = oauth_refresh_token_new(client_id, id) oauth_authorize_code_rm(authorization_id) data = { 'access_token':access_token, 'refresh_token':refresh_token, 'expires_in': 87063, 'scope': 'basic', 'user_id':user_id } self.finish(data) else: self.finish({'error':'redirect uri not same as the redirect uri of this app'}) else: self.finish({'error':'oauth secret verify error'}) else: self.finish({'error':'oauth authorization code verify error'}) else: self.finish({'error':'grant type error'})
def get(self): mail = self.get_argument('mail', None) passwd = self.get_argument('passwd', None) client_secret = self.get_argument('client_secret', None) client_id = self.get_argument('client_id', None) if mail_password_verify(mail, passwd): if oauth_secret_verify(client_id, client_secret): user_id = user_id_by_mail(mail) id, access_token = oauth_access_token_new(client_id, user_id) refresh_token = oauth_refresh_token_new(client_id, id) return self.finish({ 'user_id': user_id, 'access_token': access_token, 'refresh_token': refresh_token, 'expires_in': 87063, 'scope': 'basic' }) else: self.finish( { 'error_code':2, 'error': "oauth_secret_verify(client_id, client_secret) failed" } ) else: self.finish( { 'error_code':1 } )
def get(self): mail = self.get_argument('mail', None) passwd = self.get_argument('passwd', None) client_secret = self.get_argument('client_secret', None) client_id = self.get_argument('client_id', None) if mail_password_verify(mail, passwd): if oauth_secret_verify(client_id, client_secret): user_id = user_id_by_mail(mail) id, access_token = oauth_access_token_new(client_id, user_id) refresh_token = oauth_refresh_token_new(client_id, id) return self.finish({ 'user_id': user_id, 'access_token': access_token, 'refresh_token': refresh_token, 'expires_in': 87063, 'scope': 'basic' }) else: self.finish({ 'error_code': 2, 'error': "oauth_secret_verify(client_id, client_secret) failed" }) else: self.finish({'error_code': 1})
def get(self): client_id = self.get_argument('client_id', '') client_secret = self.get_argument('client_secret', '') redirect_uri = self.get_argument('redirect_uri', '') grant_type = self.get_argument('grant_type', '') code = self.get_argument('code', '') user_id = self.current_user_id if grant_type == 'authorization_code': if oauth_authorization_code_verify(code): authorization_id = oauth_authorization_code_verify(code) if oauth_secret_verify(client_id, client_secret): if oauth_client_uri.get(client_id) == redirect_uri: id, access_token = oauth_access_token_new( client_id, user_id) refresh_token = oauth_refresh_token_new(client_id, id) oauth_authorize_code_rm(authorization_id) data = { 'access_token': access_token, 'refresh_token': refresh_token, 'expires_in': 87063, 'scope': 'basic', 'user_id': user_id } self.finish(data) else: self.finish({ 'error': 'redirect uri not same as the redirect uri of this app' }) else: self.finish({'error': 'oauth secret verify error'}) else: self.finish({'error': 'oauth authorization code verify error'}) else: self.finish({'error': 'grant type error'})