Skip to content

Provide a way to check for access token, but not require it #167

@santtu

Description

@santtu

I have a case where an API can be accessed both with or without authentication, i.e., reduced access and capability without authentication, but with full features with authentication. This seems to be tricky to get done with the current token_auth though. It will check that

  1. Authorization header exists, if not, 401
  2. The introspection succeeds, if not, 403

I looked at #161 but it doesn't seem to address this. What I'd like is a way to programmatically check if token is supplied and it is valid or not. The introspect_token looked promising, but it will balk on a missing Authorization header.

I settled for the time being to wrap the token_auth decorator so I can intercept 401/403 if they occur and then bypass to the actual view function, but this is quite a kludge.

Since #161 is deprecating introspect_token, it doesn't seem to be a good choice anyway. Would it be possible to expose functionalities of the decorators directly or have a required=False keyword option for them?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions