hiidef / oauth2app

Django OAuth 2.0 Server App. Please fork and improve!
https://github.com/hiidef/oauth2app
MIT License
271 stars 115 forks source link

Unable to refresh token if no scope is defined #9

Closed faxioman closed 12 years ago

faxioman commented 12 years ago

Trying to refresh a token without scope defined always throw an exception. The method _validate_refresh_token in oauth2app / token should initialize self.scope to [] if no scope is used.

Thanks

bhagany commented 12 years ago

Confused about this one - what exception is being thrown in this case?

faxioman commented 12 years ago

Django try to execute this code in _get_refresh_token:

access_ranges = list(AccessRange.objects.filter(key__in=self.scope))

If self.scope is None, Django throw an exception

faxioman commented 12 years ago

I think that an "else self.scope = []" at end of _validate_refresh_token method should be resolutive.

bhagany commented 12 years ago

Looks like we had this problem in several places - I decided to check for self.scope being populated in _get_refresh_token, and the other methods like it. I believe that should solve the problem. Commit coming up.