"""Clients. Clients are external applications that are allowed to use this service. Each client provides basic information such as an id, a redirect url and a secret. For now, we don't use any external databases since we only have 3 (and the only consummer of this service will likely just be mobile analytics for a while). """ from collections import namedtuple from auth.utils import response Client = namedtuple('Client', ['id', 'name', 'redirect_url', 'secret']) clients = { # 1xxxx: for qa environments. 19874: Client( 19874, 'Mobile Analytics', 'http://qa-ows-mobile-analytics.elasticbeanstalk.com/_oauth/owsAuth', 'Sb6sdUcvMKSh2aHiXRd6ZfbK7'), # 2xxxx: for dev environments. 29874: Client( 29874, 'Mobile Analytics', 'http://localhost:3000/_oauth/owsAuth', 'Sb6sdUcvMKSh2aHiXRd6ZfbK7'), # 3xxxx: for production environments. 39874: Client( 39874, 'Mobile Analytics', 'http://m.workstation.theorchard.com/_oauth/owsAuth', 'Sb6sdUcvMKSh2aHiXRd6ZfbK7') } def fetch_one(client_id=None): """Fetch a client by its id. Args: client_id (int): the client id. Returns: Response: the response data. """ client = clients.get(client_id.value) if not client: return response.create_not_found_response(errors={ 'client': 'The client does not exist.' }) return response.Response(message=client)