-
Notifications
You must be signed in to change notification settings - Fork 431
oauth2client: django_orm.Storage locked_put should try a get/update first #528
Comments
@waprin can you take a look at this? |
yes |
@wizravi I am literally in the middle of rewriting that whole class so this is good information to be aware of. I have a rough sketch here: https://github.com/waprin/oauth2client/pull/4/files though I don't think I address the issue you're describing. If you don't mind, I can put you on the review when I submit a PR ot the main repo sometime soon (next week-ish). |
+1 for changing to overwrite=True Everyone following the docs will have the same issue because if user is the primary key for the credentials model you can't insert two credentials for the same user. To me it seems that 'get_or_create()' (the overwrite=True case) is always the right choice in this scenario. |
Agreed, I am finishing up a PR for this, just fixing tests etc. Will mention you on it. |
This issue was originally reported at : bradleybossard/google-api-python-client#278, But which look to be oauth2client issue.
Issue:
As described in the above link,
I also faced the problem where refresh was throws an IntegrityError
due to violation of the unique constrain in model.
Following change worked for me:
In oauth2client/client.py, inside "def _do_refresh_request", I changed the line self.store.locked_put(self) (in line#937) to self.store.locked_put(self, overwrite=True).
Can anyone comment if it is safe fix.
The text was updated successfully, but these errors were encountered: