oauth-2.0 为什么我得到无效的客户端错误,而试图在 Postman 后

0mkxixxg  于 2022-10-31  发布在  其他
关注(0)|答案(1)|浏览(122)

[在此处输入图像描述][1] hi i was trying to post in postman using some parameters like client_id and client secret and token which i got it from Facebook[enter image description here][2] developer app

`hi i was trying to post in postman using some parameters like client_id and client secret and token which i got it from Facebook[enter image description here][2] developer app `

# here is my reqest

url:http://localhost:8000/api/social/convert-token?grant_type=convert_token&client_id=sdklhsjgvdshfuahhddkaj37637utydew7&client_secret=dgshjhsdfkgaskflj8363589klsskjnlksfjnljhfjmj83889ij&backend=facebook&token=lkdfjlkjhdsfkljhbdsncvkjdsh763uhkdjcbgjhxsgckjdsh7ytfgklfclkfoit76ejvmljfdlkjndsi736uihd

# postman

# also my setting.py

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.

BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = 'edk,wdjhshdajldkahsgca'

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'coreapp',
    'cloudinary',
    'oauth2_provider',
    'social_django',
    'rest_framework_social_oauth2',
]

MIDDLEWARE = [
    '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 = 'foodhub.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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',
            ],
        },
    },
]

WSGI_APPLICATION = 'foodhub.wsgi.application'

# Database

# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

# Password validation

# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization

# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'

# Default primary key field type

# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGIN_REDIRECT_URL='/'
import cloudinary
import cloudinary.uploader
import cloudinary.api

# config heroku

import django_heroku
django_heroku.settings(locals())

# CSRF_TRUSTED_ORIGINS =['http://127.0.0.1:8000/restaurant/sign_up']

AUTHENTICATION_BACKENDS = (
   'social_core.backends.facebook.FacebookOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

# Facebook configuration

SOCIAL_AUTH_FACEBOOK_KEY = 'FACEBOOK_KEY'
SOCIAL_AUTH_FACEBOOK_SECRET = 'facebook_secret'

# Define SOCIAL_AUTH_FACEBOOK_SCOPE to get extra permissions from Facebook.

# Email is not sent by default, to get it, you must request the email permission.

SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
    'fields': 'id, name, email,picture.type(large)'

# the url.py

from re import template
from django.contrib import admin
from django.urls import path,include
from django.contrib.auth import views as auth_views
from django.contrib.auth import views
from coreapp import views 

urlpatterns = [
    #Web View - Admin
    path('admin/', admin.site.urls),
    path('', views.home,name='home'),

    #web View - Restaurant
    path('restaurant/sign_in/',auth_views.LoginView.as_view(template_name='restaurant/sign_in.html'),name='restaurant_sign_in'),
    path('restaurant/sign_out/',auth_views.LogoutView.as_view(next_page='/'),name='restaurant_sign_out'),
    path('restaurant/sign_up', views.restaurant_sign_up,name='restaurant_sign_up'),
     path('restaurant/', views.restaurant_home,name='restaurant_home'),

     #APIs
     # /convert-token (sing_in/sing_up) ,/revoke-token(sign-out)
    path('api/social/', include('rest_framework_social_oauth2.urls')),

]```
oyt4ldly

oyt4ldly1#

我挖了两天,我发现我的Facebook应用程序的秘密,这是从Facebook开发应用程序,所以我的帖子请求现在工作正常

相关问题