Exemplo n.º 1
0
def personal_access_token_register(auth, **kwargs):
    """Register a personal access token: blank form view"""
    token_list_url = api_v2_url("tokens/")  # POST request to this url
    return {
        "token_list_url": token_list_url,
        "token_detail_url": '',
        "scope_options": get_available_scopes()
    }
Exemplo n.º 2
0
def personal_access_token_detail(auth, **kwargs):
    """Show detail for a single personal access token"""
    _id = kwargs.get('_id')

    # The ID must be an active and existing record, and the logged-in user must have permission to view it.
    try:
        record = ApiOAuth2PersonalToken.find_one(Q('_id', 'eq', _id))
    except NoResultsFound:
        raise HTTPError(http.NOT_FOUND)
    if record.owner != auth.user:
        raise HTTPError(http.FORBIDDEN)
    if record.is_active is False:
        raise HTTPError(http.GONE)

    token_detail_url = api_v2_url("tokens/{}/".format(_id))  # Send request to this URL
    return {"token_list_url": '',
            "token_detail_url": token_detail_url,
            "scope_options": get_available_scopes()}
Exemplo n.º 3
0
def personal_access_token_detail(auth, **kwargs):
    """Show detail for a single personal access token"""
    _id = kwargs.get('_id')

    # The ID must be an active and existing record, and the logged-in user must have permission to view it.
    try:
        record = ApiOAuth2PersonalToken.objects.get(_id=_id)
    except ApiOAuth2PersonalToken.DoesNotExist:
        raise HTTPError(http.NOT_FOUND)
    if record.owner != auth.user:
        raise HTTPError(http.FORBIDDEN)
    if record.is_active is False:
        raise HTTPError(http.GONE)

    token_detail_url = api_v2_url('tokens/{}/'.format(_id))  # Send request to this URL
    return {'token_list_url': '',
            'token_detail_url': token_detail_url,
            'scope_options': get_available_scopes()}
Exemplo n.º 4
0
def personal_access_token_detail(auth, **kwargs):
    """Show detail for a single personal access token"""
    _id = kwargs.get('_id')

    # The ID must be an active and existing record, and the logged-in user must have permission to view it.
    try:
        record = ApiOAuth2PersonalToken.objects.get(_id=_id)
    except ApiOAuth2PersonalToken.DoesNotExist:
        raise HTTPError(http_status.HTTP_404_NOT_FOUND)
    if record.owner != auth.user:
        raise HTTPError(http_status.HTTP_403_FORBIDDEN)
    if record.is_active is False:
        raise HTTPError(http_status.HTTP_410_GONE)

    token_detail_url = api_v2_url('tokens/{}/'.format(_id))  # Send request to this URL
    return {'token_list_url': '',
            'token_detail_url': token_detail_url,
            'scope_options': get_available_scopes()}
Exemplo n.º 5
0
def personal_access_token_detail(auth, **kwargs):
    """Show detail for a single personal access token"""
    _id = kwargs.get('_id')

    # The ID must be an active and existing record, and the logged-in user must have permission to view it.
    try:
        record = ApiOAuth2PersonalToken.find_one(Q('_id', 'eq', _id))
    except NoResultsFound:
        raise HTTPError(http.NOT_FOUND)
    if record.owner != auth.user:
        raise HTTPError(http.FORBIDDEN)
    if record.is_active is False:
        raise HTTPError(http.GONE)

    token_detail_url = api_v2_url("tokens/{}/".format(_id))  # Send request to this URL
    return {"token_list_url": '',
            "token_detail_url": token_detail_url,
            "scope_options": get_available_scopes()}
Exemplo n.º 6
0
def personal_access_token_register(auth, **kwargs):
    """Register a personal access token: blank form view"""
    token_list_url = api_v2_url("tokens/")  # POST request to this url
    return {"token_list_url": token_list_url, "token_detail_url": "", "scope_options": get_available_scopes()}
Exemplo n.º 7
0
def personal_access_token_register(auth, **kwargs):
    """Register a personal access token: blank form view"""
    token_list_url = api_v2_url('tokens/')  # POST request to this url
    return {'token_list_url': token_list_url,
            'token_detail_url': '',
            'scope_options': get_available_scopes()}