I'm writing a repoze.who plugin and want to return JSON from the repoze.who authentication middleware and still controll the HTTP status code. How can this be done?
How can I return JSON output when repoze.who authentication fails?
130 views Asked by Martin Thorsen Ranang At
1
There are 1 answers
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in JSON
- Handling both JSON and form values in POST request body with unknown values in Golang
- JSON Body is Not Passing Certain Strings
- Custom rewriter for json
- TypeScript: Type checking while parsing an arbitrary JSON that is typed/
- I dont understand what to do with: System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.IEnumerable`1
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Dynamic Nested Multi-Dimensional Arrays in Rust
- Creating bar chart in FastAPI
- How to encode ttsJson data?
- Trying to get the id of the last element in my json file through an api
- How to give index id to my uploaded json file in FastAPI?
- JQ JSON - Values to Array
- Spring boot JSON parse error: Unexpected character error
- convert csv file with json data inside to a column, rows table in 2nd csv file
- Sigma.JS custom rendering
Related Questions in AUTHENTICATION
- Authenticate Flask rest API
- Sends a personalised error message from the back-end to the front-end with Nuxt-auth
- How to connect Spotify PKCE Authorization Boilerplate to Login-Button in React
- Laravel SPA auth with Sanctum
- _supabaseClient__WEBPACK_IMPORTED_MODULE_1__.supabase.auth.signIn is not a function
- My openID Authentication return 'You must have either https wrappers or curl enabled.'
- How to detect the Minimization of Custom Chrome Tabs on Android?
- Wordpress redirect to homepage after successfully logged in
- How to modify the prebuilt UI of authentication in aws amplify version 6 in React Native
- Creating a login system for my website, navlist not working?
- Receiving 400 bad request on post when customer auth handler is used
- Creating Azure B2B login system with Vue.js frontend & Python Django backend
- Gradio chatbot: how to export individual conversation histories?
- Set-Cookie header not forwarded by nginx to the client
- git asking for authentication when auth.json is present while running composer update
Related Questions in TURBOGEARS2
- How to intercept POST request in TurboGears/repoze.who to invalidate user session when hitting the login_handler url
- raise sa_exc.ArgumentError( sqlalchemy.exc.ArgumentError: Mapper mapped class car->car could not assemble any primary key columns for mapped table
- TurboGears2: TypeError: redirect() got an unexpected keyword argument 'pagename'
- Turbogears2: App not starting as sub-package
- Turbogears: duplicate controller method for filtered objects
- How to paginate when page using POST requests, in turbogers?
- Turbogears2 with MySQL db not update tables in multi threads
- turbogears2 multiply price and cost from rows of query
- Using Kajiki & Jinja together in Turbogears doesn't work
- Suppress 'None' in Jinja2 in TurboGears using Environment.finalize
- How to create edit forms in Turbogear
- Turbogears Toscawidget not working
- Internal Server Error 500 on my server due to DistributionNotFound who_ldap>=3.2.2
- Python with Turbogears2 : ValueError: invalid literal for int() with base 10: 'DONE'
- How to call foreign relation model Pluggable to other model Pluggable in turbogears 2.3.11?
Related Questions in REPOZE.WHO
- How to intercept POST request in TurboGears/repoze.who to invalidate user session when hitting the login_handler url
- Python WSGI Repoze.who basic Auth not asking for user and password
- How can I return JSON output when repoze.who authentication fails?
- Python syntax checkers (Pylint, Prospector...) crashing with KeyError: 'repoze.who' when run from inside Vim
- Turbogears 2: authentication, password in different table, feedback when update
- Python authentication/authorization framework
- I cannot login to own ClueReleaseManager site
- CKAN: Bad password in web interface but REST API works?
- Remove all user's cookies/sessions when password is reset
- How do I handle logouts with repoze.who (and bottle.py)?
- Is pyramid_who (repoze.who) the preferred way to do authentication for pyramid?
- login through XHR
- Deleting Pylons/Beaker session on logout
- How to access Pylons config from a repoze.who authenticator
- Turbogears change user via function calls
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
One way to accomplish this, is to implement a
repoze.whoChallenger interface. The following solution takes advantage of the fact that the WebOb exceptions, inwebob.exc, can be used as a WSGI application. The following example shows how this can be used in a hypothetical Facebook plugin, where the 2.x API lets users not grant access to their email, which might be required for a successful registration/authentication:A central point here is that
response, an instance of a sub-class ofwebob.exc.WSGIHTTPException, is used as a WSGI application, but also that ifresponse'sbodyattribute is set, then it is not automatically generated, a fact we use to explicitly set the response's body to a JSON-formatted string representation of our dictionary. If the above challenger is invoked during the handling of a request to a URL ending in '.json' or theAcceptheader includesapplication/json, the body of the response might render as something like:and if not, then the body will be rendered as HTML: