import requests


def register_app(client_name, host, redirect_uris='urn:ietf:wg:oauth:2.0:oob',
                 scopes='read write follow'):
    """Register application

    Usage:

        >>> d = register_app('myapp', host='pawoo.net')
        >>> d
        {'id': 1234, 'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'client_id': '...', 'client_secret': '...'}

    """
    data = {
        'client_name': client_name,
        'redirect_uris': redirect_uris,
        'scopes': scopes,
    }
    resp = requests.post("https://{host}/api/v1/apps".format(host=host), data=data)
    resp.raise_for_status()
    return resp.json()