【问题标题】:How to allow images from facebook cdn in Ionic app?如何在 Ionic 应用程序中允许来自 facebook cdn 的图像?
【发布时间】:2017-11-06 11:16:44
【问题描述】:

我突然无法在我的 Ionic 1 应用(使用 Facebook 提供商的 Firebase 身份验证)中从 Facebook (https://scontent.xx.fbcdn.net) 加载个人资料图片。这以前有效,但现在我只得到一个空白图像(可能是某种 4xx 错误代码?)。 iOS 和 Android。

我安装了cordova-plugin-whitelist,我的config.xml 安装了<access origin="*"/>

我尝试添加 content-security-policy 元标记,但没有任何运气:

<meta http-equiv="Content-Security-Policy" content="img-src *  blob: android-webview-video-poster: cdvphotolibrary:  'self' data: ws: wss://*; default-src * blob: 'self' gap: wss: ws: data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src * http: https: ws: wss://*;">

有什么想法吗?我知道这以前有效,所以 Cordova 或 iOS/Android 中可能有一些变化导致了这种情况?

谢谢!

更新

我尝试使用其他外部图像,例如报纸上的随机图像,然后我就开始工作了。这可能是某种 Facebook 身份验证错误吗?

ionic info
--------------------------------
--------------------------------

Your system information:

Cordova CLI: 6.3.1
Gulp version:  CLI version 1.2.1
Gulp local:   Local version 3.9.1
Ionic Framework Version: 1.3.2
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
ios-deploy version: 1.8.6 
ios-sim version: 5.0.6 
OS: Mac OS X Sierra
Node Version: v4.4.0
Xcode version: Xcode 8.3.1 Build version 8E1000a

【问题讨论】:

    标签: facebook cordova ionic-framework firebase-authentication content-security-policy


    【解决方案1】:

    我设法通过手动获取个人资料图片解决了这个问题。 Firebase SDK 提供的图片还是不行。

    var user = firebase.auth().currentUser;
    
    if (user != null) {
      user.providerData.forEach(function (profile) {
        if (profile.providerId === "facebook.com") {
          user.updateProfile({
            photoURL : "https://graph.facebook.com/" + profile.uid + "/picture?height=200"
          });
        }
      });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-04
      • 2014-11-02
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-18
      相关资源
      最近更新 更多