- Notifications
You must be signed in to change notification settings - Fork329
Fix 'WSGIRequest' object does not support item assignment error#152
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
- Delete request arguments in functions. It is redundant as the first argument is usually the request object- Call the session method on the request object (web_app_session.session). This fixes `self.session[self.csrf_token_session_key] = csrf_token` error
greg-db commentedJul 22, 2018
Thanks! |
iamlordaubrey commentedJul 23, 2018
@starforever might I also suggest changing |
starforever left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think the error happens when you pass in an object forweb_app_session which should actually be adict.
I think we should keep these parameters simple, rather than making them some objects with fields likesession orquery_params without explicitly specifying how they are constructed. This makes it easier for others to understand the example code regardless of what libraries they use for building requests.
| oauth_result =\\ | ||
| get_dropbox_auth_flow(web_app_session).finish( | ||
| get_dropbox_auth_flow(web_app_session.session).finish( | ||
| request.query_params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If you removerequest you need to find proper replacement for all its usages within the function. Otherwise the code will break.
iamlordaubrey commentedJul 31, 2018
Ok, I think I understand. DropboxOAuth2Flow class needs to take in web_app_session. However, the documentation would be wrong for Django's implementation because the URL handlers for It is that request's session ( My point is, Therefore for Django: defget_dropbox_auth_flow(web_app_session):redirect_uri="https://my-web-server.org/dropbox-auth-finish"returnDropboxOAuth2Flow(APP_KEY,APP_SECRET,redirect_uri,web_app_session,"dropbox-auth-csrf-token")# URL handler for /dropbox-auth-startdefdropbox_auth_start(request):authorize_url=get_dropbox_auth_flow(request.session).start()redirect_to(authorize_url)# URL handler for /dropbox-auth-finishdefdropbox_auth_finish(request):try:oauth_result= \get_dropbox_auth_flow(request.session).finish(request.query_params)exceptBadRequestException,e:http_status(400) ... For Flask, session is global. We would just need to access it directly: fromflaskimportsession,requestdefget_dropbox_auth_flow(web_app_session):redirect_uri="https://my-web-server.org/dropbox-auth-finish"returnDropboxOAuth2Flow(APP_KEY,APP_SECRET,redirect_uri,web_app_session,"dropbox-auth-csrf-token")# URL handler for /dropbox-auth-start@app.route('/dropbox-auth-start')defdropbox_auth_start():authorize_url=get_dropbox_auth_flow(session).start()redirect_to(authorize_url)# URL handler for /dropbox-auth-finish@app.route('/dropbox-auth-finish')defdropbox_auth_finish():try:oauth_result= \get_dropbox_auth_flow(session).finish(request.query_params)exceptBadRequestException,e:http_status(400) ... The documentation specified two arguments, I think with Django's implementation, implementing for Flask would be clear and straightforward to a newbie. |
rogebrd commentedMar 30, 2020
Hello, is this something you are still interested in working on? |
iamlordaubrey commentedMar 30, 2020
Sure@rogebrd. I'll take a look at the failing test |
CLAassistant commentedApr 16, 2022
|
Uh oh!
There was an error while loading.Please reload this page.
self.session[self.csrf_token_session_key] = csrf_tokenerror