簡體   English   中英

Angular JS- Dreamfactory-無法連接:403禁止錯誤

[英]Angular JS- Dreamfactory - Unable to connect : 403 Forbidden error

我在Amazon Cloud EC2 DSP 1.8.0上。

根據他們在AngularJS上的文檔,這就是我聲明常量的方式:-

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services','**ngDreamFactory**'])
      .constant('DSP_URL', 'http://***-**-**-***-**.ap-southeast-1.compute.amazonaws.com/')
      .constant('DSP_API_KEY', 'sql')

上面的URL是ec2實例地址。

這是應用程序啟動時在控制台中出現的錯誤:

- GET http://***-**-**-***-**.ap-southeast-1.compute.amazonaws.com/rest/api_docs 403 (Forbidden) 

undefined : undefined http://***-**-**-***-**.ap-southeast-1.compute.amazonaws.com/rest/api_docs

即使我尚未對DSP進行任何調用,也會出現上述錯誤,因此我認為它必須是進行此調用的框架。 我看到這個“ / rest / api_docs”正在被添加到作為Angular SDK的一部分添加的JS文件中。

只是為了確認我的DSP設置正確且URL正確,這是將其粘貼到瀏覽器中時得到的:

- http://***-**-**-***-**.ap-southeast-1.compute.amazonaws.com/rest/api_docs?app_name=sql

{
  "swaggerVersion":"1.2",
  "apiVersion":"1.0",
  "authorizations":{ 
      "apiKey": {
          "type":"apiKey",
          "passAs":"header"
       }
   },
"info": {
    "title":"DreamFactory Live API Documentation",
    "description":"",
    "contact":"support@dreamfactory.com",
    "license":"Apache 2.0",
    "licenseUrl":"http://www.apache.org/licenses/LICENSE-2.0.html"},
    "events":[ 
       "swagger.cache_cleared",
       "swagger.cache_rebuilt"
    ],
    "apis":[
       {
          "path":"/user",
          "description":"User session and profile"
       },
       {
          "path":"/system",
          "description":"System configuration"
       },
       {
          "path":"/db",
          "description":"Local database access"
       },
       {
          "path":"/email",
          "description":"Email utility access"
       },
       {
          "path":"/files",
          "description":"Local file storage access"
       },
       {
          "path":"/sql",
          "description":"Amazon RDS Sql"
       }
   ]
}

因此,我認為設置正確。

在DSP端:-1)我已經定義了一個角色“ Amazon RDS”,並賦予了該角色“ sql”服務訪問權限。 另外,嘗試授予系統訪問權限。 還是行不通。 2)在Config內部的CORS訪問中,我在主機中添加了*,並選擇了所有HTTP動詞並啟用了它們。 3)選中“允許來賓用戶”,還為來賓用戶選擇了角色“ Amazon RDS”。

因此,當我稍后在代碼中進行此調用時:-DreamFactory.api.db.getRecords出現錯誤:

- TypeError: Cannot read property 'getRecords' of undefined

因為安裝服務本身未正確實例化。 在這方面的任何幫助將是有幫助的。

403表示您無權訪問該應用程序。 如果您尚未創建該應用程序,或者您的角色沒有訪問該應用程序的權限,則可能會發生這種情況。 查看此鏈接以獲取更多信息。

http://community.dreamfactory.com/t/unable-to-access-dsp-from-angularjs-mobile-app/478/14

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM