简体   繁体   中英

Angular JS- Dreamfactory - Unable to connect : 403 Forbidden error

I am on Amazon Cloud EC2 DSP 1.8.0.

Following their docs on AngularJS this is how I am declaring my constants:-

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.

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. I see this "/rest/api_docs" is getting added in the JS file added as a part of Angular SDK.

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:

- 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. 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. 3) Checked the "Allow Guest Users" and also Selected the role "Amazon RDS" for guest users.

So, when I make this call later in my code:- DreamFactory.api.db.getRecords I get the error:

- 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM