Invalid backend when converting token on server
See original GitHub issueHey there! First of all thank you for keeping this project alive.
I’ve been struggling a little bit to get things working on the server. When running locally it works like a charm:
But when I try to do the same on the server (over https) I’m getting the Invalid backend parameter
error:
It’s the same error if I try with facebook
or google-oauth2
backends.
Here are the configs:
DEBUG = False
CORS_ORIGIN_ALLOW_ALL = DEBUG
CORS_ALLOWED_ORIGINS = ['http://localhost:4201', 'http://localhost:8000',
'https://desenv.valuemachine.com.br', 'https://valuemachine.com.br']
ALLOWED_HOSTS = ['localhost',
'desenv.valuemachine.com.br', 'valuemachine.com.br']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'corsheaders',
'django_filters',
'drf_yasg',
'oauth2_provider',
'social_django',
'drf_social_oauth2',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mercado_financeiro.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
],
},
},
]
REST_FRAMEWORK = {
'PAGE_SIZE': 20,
'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',
'DEFAULT_PAGINATION_CLASS': 'rest_framework_json_api.pagination.JsonApiPageNumberPagination',
'DEFAULT_AUTHENTICATION_CLASSES': [
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
'drf_social_oauth2.authentication.SocialAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.AllowAny',
],
'DEFAULT_PARSER_CLASSES': [
'rest_framework_json_api.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser'
],
'DEFAULT_RENDERER_CLASSES': [
'rest_framework_json_api.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
],
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
'DEFAULT_FILTER_BACKENDS': [
'rest_framework_json_api.filters.QueryParameterValidationFilter',
'rest_framework_json_api.filters.OrderingFilter',
'rest_framework_json_api.django_filters.DjangoFilterBackend',
'rest_framework.filters.SearchFilter',
],
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
'SEARCH_PARAM': 'filter[search]',
'ORDERING_PARAM': 'sort',
'TEST_REQUEST_RENDERER_CLASSES': [
'rest_framework_json_api.renderers.JSONRenderer',
],
'TEST_REQUEST_DEFAULT_FORMAT': 'vnd.api+json'
}
AUTHENTICATION_BACKENDS = (
'social_core.backends.facebook.FacebookAppOAuth2',
'social_core.backends.facebook.FacebookOAuth2',
'social_core.backends.google.GoogleOAuth2',
'social_core.backends.linkedin.LinkedinOAuth2',
'drf_social_oauth2.backends.DjangoOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
# Facebook configuration
SOCIAL_AUTH_FACEBOOK_KEY = 'xxxx'
SOCIAL_AUTH_FACEBOOK_SECRET = 'xxxx'
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
'fields': 'id, name, email'
}
# Google configuration
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'xxxx'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'xxx'
SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
]
Have you ever had this issue? Do you have a clue about it? I’m very confused about this because it was supposed to work just fine since it is working when I am running locally.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Invalid backend parameter · Issue #147 - GitHub
When I send request to http://localhost:8000/auth/convert-token with body { 'grant_type': 'convert_token', 'client_id': '******', 'backend': ...
Read more >Invalid Token when using oauth on backend server call
Using Python to implement a backend service call to verify a user by login. The token call comes back with a token but...
Read more >Is it possible to invalidate a token with stateless logic (no ...
Backend : Create a random key and save it static database. When client request for token create a token(+base64 conversion) using random key...
Read more >Handling an invalid Link Token - Docs - Plaid
Learn how to handle invalid Link tokens by catching the error in the onExit callback and re-fetching a new link_token for the next...
Read more >Best practices for FCM registration token management
On this page · Basic best practices. Retrieve and store registration tokens; Detect invalid token responses from the FCM backend · Ensuring registration...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @crozarakamilla. Thank you.
I have seen this error before. I realised it was because I didn’t have an Application called
facebook
in production. Can you cehck that please?@crozarakamilla and @timothyshen
Did you manage to overcome this situation?