def is_valid_token(token): """Check that the user has a valid token.""" # Set auth object auth = Auth(token) try: # Make request result = auth.test() except Error as err: # Check for auth errors stf.report_event(str(err), { 'token': token }) return False # Check for further errors if not result.successful: stf.report_event('token_invalid', { 'token': token, 'result': result.__dict__ }) return False # Return successful return True
def is_valid_token(token): """Check that the team has a valid token.""" # Set auth object auth = Auth(token) try: # Make request result = auth.test() except Error as err: # Check for auth errors report_event(str(err), { 'token': token }) return False # Check for further errors if not result.successful: report_event('token_invalid', { 'token': token, 'result': result.__dict__ }) return False # Return successful return True
def validate_token(token): ''' Validates token and retrieves info from Slack API ''' # Set auth object auth = Auth(token) try: # Make request result = auth.test() except Error: abort(400) # Check for errors if not result.successful: abort(400) # Return user info return result.body
def validate_token(token): """Validate token and retrieves info from Slack API.""" # Set auth object auth = Auth(token) try: # Make request result = auth.test() except Error as err: report_event(str(err), {"token": token}) abort(400) # Check for errors if not result.successful: report_event("token_invalid", {"token": token, "result": result.__dict__}) abort(400) # Return user info return result.body
def is_valid_token(token): ''' Checks that the user has a valid token ''' # Set auth object auth = Auth(token) try: # Make request result = auth.test() except Error: # Check for auth errors return False # Check for further errors if not result.successful: return False # Return successful return True
def validate_token(token): """Validate token and retrieves info from Slack API.""" # Set auth object auth = Auth(token) try: # Make request result = auth.test() except Error as err: report_event(str(err), {'token': token}) abort(400) # Check for errors if not result.successful: report_event('token_invalid', { 'token': token, 'result': result.__dict__ }) abort(400) # Return user info return result.body