#NEWLINE# @ classmethod #NEWLINE# def get_groups_by_token( cls , username , token , request ) : #NEWLINE# #INDENT# " Get user's groups if user with :username: exists and their api key\n        token equals :token:\n\n        Used by Token-based authentication as `check` kwarg.\n        " #NEWLINE# try : #NEWLINE# #INDENT# user = cls . get_item ( username = username ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# log . error ( str ( ex ) ) #NEWLINE# forget ( request ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( user and ( user . api_key . token == token ) ) : #NEWLINE# #INDENT# return [ ( 'g:%s' % g ) for g in user . groups ]