Skip to content

Documentation missing for DRF TokenHasResourceScope behavior #410

Open
@evitolins

Description

@evitolins

The DRF permissions class TokenHasResourceScope requires tokens use a colon-separated syntax to explicitly specify read/write scopes (ie. "music:read music:write"). This scope syntax is mentioned nowhere within the docs as far as I've found.

The following info seems like it would be necessary to understand to successfully utilize this workflow.


Based on this example from the TokenHasResourceScope docs....

class SongView(views.APIView):
    authentication_classes = [OAuth2Authentication]
    permission_classes = [TokenHasResourceScope]
    required_scopes = ['music']
    ...

Token Scope Syntax

A valid token's scope is set in this fashion, to grant both read and write permissions for this view.

music:read music:write

However, defining a token's scope without appending specific read and/or write access will not work

music

Settings

Within your scope settings, you must declare each scope explicitly

OAUTH2_PROVIDER = {
    'SCOPES': {
        'music:read' : 'Read music accessible by your account.',
        'music:write' : 'Write music accessible by your account.',
        ...
    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions