简体   繁体   English

Angular JS- Dreamfactory-无法连接:403禁止错误

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

I am on Amazon Cloud EC2 DSP 1.8.0. 我在Amazon Cloud EC2 DSP 1.8.0上。

Following their docs on AngularJS this is how I am declaring my constants:- 根据他们在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')

The URL above is the ec2 instance address. 上面的URL是ec2实例地址。

This is the error I get in the console when the app starts: 这是应用程序启动时在控制台中出现的错误:

- 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

The above error comes, even though I have not yet made any call to the DSP, so I assume it must be the framework making this call. 即使我尚未对DSP进行任何调用,也会出现上述错误,因此我认为它必须是进行此调用的框架。 I see this "/rest/api_docs" is getting added in the JS file added as a part of Angular SDK. 我看到这个“ / rest / api_docs”正在被添加到作为Angular SDK的一部分添加的JS文件中。

Just to confirm that my DSP is set up correctly and my URL is correct, this is what I get when I paste this in the browser: 只是为了确认我的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"
       }
   ]
}

Therefore, I assume the set up is correct. 因此,我认为设置正确。

At the DSP end:- 1) I have defined a role, as "Amazon RDS" and have given service access of 'sql' to this role. 在DSP端:-1)我已经定义了一个角色“ Amazon RDS”,并赋予了该角色“ sql”服务访问权限。 Also, tried giving system access. 另外,尝试授予系统访问权限。 Still not working. 还是行不通。 2) In the CORS access inside Config, I have added * in the Host and selected all the HTTP verbs and enabled the same. 2)在Config内部的CORS访问中,我在主机中添加了*,并选择了所有HTTP动词并启用了它们。 3) Checked the "Allow Guest Users" and also Selected the role "Amazon RDS" for guest users. 3)选中“允许来宾用户”,还为来宾用户选择了角色“ Amazon RDS”。

So, when I make this call later in my code:- DreamFactory.api.db.getRecords I get the error: 因此,当我稍后在代码中进行此调用时:-DreamFactory.api.db.getRecords出现错误:

- TypeError: Cannot read property 'getRecords' of undefined

Because the setup service itself is not getting instantiated properly. 因为安装服务本身未正确实例化。 Any help in this regard would be helpful. 在这方面的任何帮助将是有帮助的。

A 403 means you don't have access to the app. 403表示您无权访问该应用程序。 This can happen if you haven't created the app yet or your role doesn't have permission to access that app. 如果您尚未创建该应用程序,或者您的角色没有访问该应用程序的权限,则可能会发生这种情况。 Check out this link for more info. 查看此链接以获取更多信息。

http://community.dreamfactory.com/t/unable-to-access-dsp-from-angularjs-mobile-app/478/14 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