@app.before_request
def before_remote_request():
 if ((request.endpoint in ('namespace_api.message_search_api', 'namespace_api.thread_search_api', 'namespace_api.message_streaming_search_api', 'namespace_api.thread_streaming_search_api')) or (request.method in ('POST', 'PUT', 'PATCH', 'DELETE'))):
  if g.namespace:
   request.environ['log_context']['provider'] = g.namespace.account.provider
  valid_account(g.namespace)

@ app . before_request def before_remote_request ( ) : if ( ( request . endpoint in ( 'namespace_api.message_search_api' , 'namespace_api.thread_search_api' , 'namespace_api.message_streaming_search_api' , 'namespace_api.thread_streaming_search_api' ) ) or ( request . method in ( 'POST' , 'PUT' , 'PATCH' , 'DELETE' ) ) ) : if g . namespace : request . environ [ 'log_context' ] [ 'provider' ] = g . namespace . account . provider valid_account ( g . namespace )
verify the validity of the accounts credentials before performing a request to the remote server .