Facebook JavaScript SDK不适用于Chrome扩展程序 [英] The Facebook JavaScript SDK does not work on chrome extension

查看:102
本文介绍了Facebook JavaScript SDK不适用于Chrome扩展程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个chrome扩展程序.该扩展程序的功能包括Facebook登录.该扩展不支持外部JavaScript链接,因此我必须在扩展的清单文件中创建"content_security_policy".现在它可以工作了,它正在加载Facebook SDK的外部文件.我现在面临的问题是;在Facebook开发人员帐户中创建应用程序时,我将域和URL设置为 http://localhost.com/ ,当我在扩展程序上运行SDK脚本时,显示错误消息:

I am writing up a chrome extension. The functionality of the extension includes the Facebook login. The extension does not support external JavaScript links so for that I had to make "content_security_policy" in the manifest file of extension. And now it works, it is loading the external file of Facebook SDK. The problem I am facing now is; while creating the app in Facebook developers account, I gave the domain and URL as http://localhost.com/ and when I run SDK script on my extension it shows an error which is :

无法加载URL:此URL的域未包含在应用程序的域中.为了能够加载此URL,请将应用程序的所有域和子域添加到应用程序设置的应用程序域"字段中.

Can't load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and sub-domains of your app to the App Domains field in your app settings.

当我加载URL时,它向我显示了链接:

And when I load the URL it shows me the link :

chrome-extension://hpkkicffiddlopkeiobamkfhfbbofmel/index.html

chrome-extension://hpkkicffiddlopkeiobamkfhfbbofmel/index.html

通过将此URL放置在Facebook开发人员应用中,它会给我带来无效错误.我现在该怎么办?

By placing this URL in the Facebook developers app, it giving me invalidity error. What should I do now?

推荐答案

由于此限制,您不能在Chrome扩展程序中使用JavaScript SDK进行OAuth登录-您无法重定向到扩展程序页面.

You can't use the JavaScript SDK for OAuth logins in a Chrome extension because of this limitation - you can't redirect to an extension page.

您可以使用 chrome.identity API ,它提供了非chrome-extension:虚拟可以与Facebook一起使用的URL.这将为您提供与其他Facebook API一起使用的令牌.

You can use chrome.identity API, which gives a non-chrome-extension: virtual URL that is OK to use with Facebook. That will give you the token to use with other Facebook APIs.

有示例代码此处.

或者,您也可以整个OAuth流程手动.

这篇关于Facebook JavaScript SDK不适用于Chrome扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆