Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to set access_token as attribute #43

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oauth2app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Client(models.Model):
unique=True,
max_length=CLIENT_SECRET_LENGTH,
default=KeyGenerator(CLIENT_SECRET_LENGTH))
can_self_grant = models.BooleanField(default=False)
redirect_uri = models.URLField(null=True)


Expand Down
4 changes: 3 additions & 1 deletion oauth2app/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ def _validate(self):

def _validate_access_credentials(self):
"""Validate the request's access credentials."""
if not self.client.can_self_grant:
raise InvalidClient('Client authentication failed.')
if self.client_secret is None and "HTTP_AUTHORIZATION" in self.request.META:
authorization = self.request.META["HTTP_AUTHORIZATION"]
auth_type, auth_value = authorization.split()[0:2]
Expand Down Expand Up @@ -405,7 +407,7 @@ def _get_refresh_token(self):

def _get_client_credentials_token(self):
"""Generate an access token after client_credentials authorization."""
access_token = AccessToken.objects.create(
self.access_token = AccessToken.objects.create(
user=self.client.user,
client=self.client,
refreshable=self.refreshable)
Expand Down