我正在使用Google App Engine和烧瓶从Facebook获取身份验证 我创建了FB应用程序,它连接正常
我正在使用以下库
我正在设置CORS设置如下
cors = CORS(app, resources={r"/api/v1/*": {"origins": "*"}})
我收到以下错误
XMLHttpRequest cannot load https://www.facebook.com/dialog/oauth?response_type=code&client_id=40400553…alhost%3A8080%2Fapi%2Fv1%2Fusers%2Ffacebook2%2F&scope=email&_external=True. Redirect from 'https://www.facebook.com/dialog/oauth?response_type=code&client_id=40400553…alhost%3A8080%2Fapi%2Fv1%2Fusers%2Ffacebook2%2F&scope=email&_external=True' to 'https://www.facebook.com/login.php?skip_api_login=1&api_key=404005532980775…_&display=page&locale=en_GB&logger_id=c25bd044-3438-4a9b-b9ef-3f1701bf1d1c' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
请求处理程序
SECRET_KEY = 'development key'
DEBUG = True
FACEBOOK_APP_ID = '40400553-----'
FACEBOOK_APP_SECRET = 'bc04c3c33f-----'
facebook_config = dict(
access_token_url='/oauth/access_token',
authorize_url='/oauth/authorize',
base_url='https://graph.facebook.com/',
consumer_key=FACEBOOK_APP_ID,
consumer_secret=FACEBOOK_APP_SECRET,
request_token_params={'scope': 'email'},
)
def create_oauth_app(service_config, name):
upper_name = name.upper()
app.config[upper_name] = service_config
service_oauth = oauth.OAuth()
service_app = service_oauth.remote_app(name, app_key=upper_name)
service_oauth.init_app(app)
return service_app
def signin_fb_oauth(oauthapp, scheme=None):
try:
flask.session.pop('oauth_token', None)
save_request_params()
print '****************************'
print 'signin oauth'
print '*******************************'
#call_back_url_appengine = 'http://localhost:3000/api/v1/users/facebook2/'
call_back_url_flask= 'http://localhost:8080/api/v1/users/facebook2/'
fb_auth = oauthapp.authorize(
callback=call_back_url_flask,
_external=True
)
return fb_auth
except oauth.OAuthException:
flask.flash(
'Something went wrong with sign in. Please try again.',
category='danger',
)
print '*******************************************'
print 'Error in AuthenticationError'
print '*******************************************'
return flask.redirect(flask.url_for('signin', next=util.get_next_url()))
此应用程序具有Angualr2前端和Flask Google App Engine后端
这里可能出现什么问题?