def get_user_auth(request):
 user = request.user
 private_key = request.query_params.get('view_only', None)
 if user.is_anonymous():
  auth = Auth(None, private_key=private_key)
 else:
  auth = Auth(user, private_key=private_key)
 return auth

def get_user_auth ( request ) : user = request . user private_key = request . query_params . get ( 'view_only' , None ) if user . is_anonymous ( ) : auth = Auth ( None , private_key = private_key ) else : auth = Auth ( user , private_key = private_key ) return auth
given a django request object .