示例#1
0
文件: script.py 项目: hylhero/h
def token(args):
    """
    Generate an OAuth bearer token for the specified principal.

    This token is suitable for authenticating HTTP requests to the h API.

    For example, to authorize yourself as user seanh to your local dev instance
    of h do:

        hypothesis token --base 'http://*****:*****@localhost' conf/development.ini

    Then copy the output and pass it to the h API as the value of an
    X-Annotator-Auth-Token header.

    """
    from h.auth import get_client, generate_signed_token

    request = bootstrap(args)
    registry = request.registry

    request.client = get_client(request, registry.settings['h.client_id'])
    request.user = args.sub
    request.expires_in = args.ttl
    request.extra_credentials = {}

    token = generate_signed_token(request)

    print(token)
示例#2
0
def token(args):
    """
    Generate an OAuth bearer token for the specified principal.

    This token is suitable for authenticating HTTP requests to the h API.

    For example, to authorize yourself as user seanh to your local dev instance
    of h do:

        hypothesis token --base 'http://*****:*****@localhost' conf/development.ini

    Then copy the output and pass it to the h API as the value of an
    X-Annotator-Auth-Token header.

    """
    from h.auth import get_client, generate_signed_token

    request = bootstrap(args)
    registry = request.registry

    request.client = get_client(request, registry.settings['h.client_id'])
    request.user = args.sub
    request.expires_in = args.ttl
    request.extra_credentials = {}

    token = generate_signed_token(request)

    print(token)
示例#3
0
def token(args):
    """Generate an OAuth bearer token for the specified principal."""
    from h.auth import get_client, generate_signed_token

    if not args.config_uri.endswith('#api'):
        args.config_uri += '#api'

    paster.setup_logging(args.config_uri)
    env = paster.bootstrap(args.config_uri)
    request = env['request']
    registry = env['registry']

    request.client = get_client(request, registry.settings['h.client_id'])
    request.user = args.sub
    request.expires_in = args.ttl
    request.extra_credentials = {}

    token = generate_signed_token(request)

    print(token)
示例#4
0
文件: script.py 项目: bbarker/h
def token(args):
    """Generate an OAuth bearer token for the specified principal."""
    from h.auth import get_client, generate_signed_token

    if not args.config_uri.endswith('#api'):
        args.config_uri += '#api'

    paster.setup_logging(args.config_uri)
    env = paster.bootstrap(args.config_uri)
    request = env['request']
    registry = env['registry']

    request.client = get_client(request, registry.settings['h.client_id'])
    request.user = args.sub
    request.expires_in = args.ttl
    request.extra_credentials = {}

    token = generate_signed_token(request)

    print(token)