Error creating oauth access token using django-oauth2-provider - django

When I send a HTTP POST request to create an access token for a user, with parameters client_id, client_secret, username, password etc., to my localhost which has Django (v1.7) running, I get an access token in response.
But when I do the same to Django (v1.7) deployed on Elastic Beanstalk, I get
TypeError at /oauth2/access_token
__init__() got an unexpected keyword argument 'mimetype'
I used to get this error earlier when I was using Django 1.8 but then I downgraded to Django 1.7 and this error got resolved. This all was done locally, in localhost. But when I deployed to beanstalk, I again get this error even though the version deployed there is 1.7.

This error happen because pass mimetype to HttpResponse was removed of Django 1.7 ( https://github.com/django/django/commit/8eadbc5a03d06f5bfedfa3fad35ad0801d2ab6ff ).
I believe that some possibilities are,
You can use another solution as django-oauth-toolkit;
You can change line 491 at
https://github.com/caffeinehit/django-oauth2-provider/blob/master/provider/views.py#L491
to use content_type instead of mimetype;
Or you can use a django-oauth2-provider fork that already resolved it developed by glassresistor user. In this case you can:
Install with pip
$ pip install https://github.com/glassresistor/django-oauth2-provider/archive/stable.zip#django-oauth2-provider
or add directly in requirements.txt:
-e git+https://github.com/glassresistor/django-oauth2-provider.git#egg=django-oauth2-provider

Related

No module named 'graphene_djangographql_jwt'

I got error when I add graphql_jwt.refresh_token.apps.RefreshTokenConfig in INSTALLED_APPS. I ran the command " pip install django-graphql-jwt" but there is still some packages problems. Does anybody know about it?
I am expecting to use GraphQL url with Django. I was going to give request access only auth users.

Internal server error running Django on Heroku accessing from browser

I think this is a simple fix, but I've deployed quite a few Django apps to Heroku and I still can't figure out what's going on.
Accessing https://dundjeon-finder.herokuapp.com/ gives me a 500 error when using the browser/curl, but if I shell into the app using heroku run ./manage.py shell I can render the views no problem. My logs aren't telling me anything (just that the response is 500) despite DEBUG being set to True, and Sentry isn't receiving an error (it has previously when the database env variable was set badly), so I'm assuming it's something to do with the way the request works.
The repo is public, any help would be much appreciated! The settings file is here.
Well it was because of using asgi instead of wsgi. I'm not sure why that caused the errors, but will do some more searching.

API is not working in flutter_web(Enabled CORS)

I Made one POST API in Django rest framework. It working perfectly in Postman in also chrome and other browsers but it is not working in my flutter_web project. it is giving me XMLHttpRequest error. for enable CORS I had used python -m pip install django-cors-headers.
you can check my api from https://findweight.herokuapp.com/idealweight which takes raw data for example 5.
you can check my whole error from following image:- https://i.stack.imgur.com/Fx8Xp.png
Make sure that you have applied all the migrations properly on the backend.
If not then migrate it first by python manage.py migrate.
And restart your server again and see the logs by changing DEBUG = True,
So you can see what is the error (NOTE: Make sure you change DEBUG = False before going to production).
And also, check if you have set up CORS property properly on the backend.

In production Page not Found Error when trying to access Django /admin on deployed Heroku app

Friends -
I have a django app (build with cookiecutter) and I have it deployed on Heroku, following these steps here:
https://cookiecutter-django.readthedocs.io/en/latest/deployment-on-heroku.html
Everything works fine and I can also create instances in the database. Now, when I try to enter the admin-page with /admin I get an 404 Page not found error.
When deploying I had this error: (which I ignored)
remote: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first.
remote: --> Continuing using default collectstatic.
I ignored this error because I everything was working. Now, could that be connected or am I just missing something here?
I assume I after deployment I should be able to login to the django admin section, or am I mistaken? I set my admin url in my .env file, but still, I get this problem. Locally everything runs perfectly....
Any help or hints are very much appreciated!

Heroku Server 500 error on particular page

Just deployed a Django app on Heroku. Everything works except for one page of my site which creates a Server 500 error (even though it works fine on my local development server).
The page raising the error doesn't do anything unusual. It makes some database calls, renders some forms, implements JQuery, etc. Any clue what this could be or how I can debug it?
Also, I thought this might be a data issue since my data in Dev doesn't match my data in production, but I checked and this doesn't seem to be the cause.
enable DEBUG=TRUE in your django settings.py file or type in console heroku logs --app your_app to get heroku server logs.
This was because I didn't include a runtime.txt telling Heroku to use Python 3 instead of 2 which subsequently raised an error in one of my views where I called super() with no args.