我正在尝试使用Facebook的Javascript SDK在Chrome扩展程序的popup.html页面中实现登录按钮。但是,当我调用FB.login()函数时,我会收到以下错误:Given URL is not allowed by the Application configuration。由于这是一个Chrome扩展程序,我不确定是否可以为其提供URL或域名。那么,在这种情况下我应该怎么办呢?
Native or desktop app?
和Embedded browser OAuth Login
选项。 - Jatin我也在尝试在我的Chrome扩展中添加fb-login功能。 我正在使用python-socialauth作为Django应用程序中Facebook的身份验证应用程序,这是后端。
我遵循的步骤如下:
首先,我打开了一个带有Facebook登录链接的窗口:
window.open('https://www.facebook.com/dialog/oauth?client_id=&response_type=token&redirect_uri=,"Facebook login", "width=635,height=290,left=0,top=0")
从成功的URL中,我检索到了访问令牌并保存在chrome-local-storage中。
然后,我将令牌发送到我的django-facebook-login视图。 但是它出现了错误:
'Nonetype' object has no attribute 'encode'.
我的代码如下:
if isinstance(request.backend, BaseOAuth1):
if request.REQUEST.get('backend') == "facebook":
oauth_token_secret = settings.SOCIAL_AUTH_FACEBOOK_KEY
if request.REQUEST.get('backend') == "google-oauth2":
oauth_token_secret = settings.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET
token = {
'oauth_token': request.REQUEST.get('access_token'),
'oauth_token_secret': oauth_token_secret,
}
elif isinstance(request.backend, BaseOAuth2):
token = request.REQUEST.get('access_token')
else:
raise HttpResponseBadRequest('Wrong backend type')
user = request.backend.do_auth(token, ajax=True)
# age = request.POST.get('age', '')
login(request, user)