Miserlou/Zappa

Forbidden message

Opened this issue · 8 comments

Context

After successfully deploying my Flask application, I am having trouble accessing it. When I make a request using Postman, for example, I receive "Forbidden" as a message.

Expected Behavior

After finishing the deployment, I received a link for my app and tried accessing the routes I programmed in Flask. I expected that passing it through Postman, and adding the api_key as authentication, I would be able to access my API.

Actual Behavior

Instead, I am getting "Forbidden" as a return for my call.

Possible Fix

After making some diggings here, I suspected that using the api_key function could be the problem. Someone suggested that I should change the configuration in AWS Gateway API > Custom Domain Names but there are no API registered there, which raised some warnings in my head. Maybe there is a problem in my permission of AWS that is not allowing it to create the project on Gateway API? I don't know.

After suspecting that the api_key_required camp could be the problem, I removed it. But instead, I got another error: "TypeError: 'NoneType' object is not callable. Now I am even more lost.

Steps to Reproduce

  1. zappa init
  2. zappa deploy dev

Your Environment

  • Zappa version used:
  • Operating System and Python version: MacOS 10.14 / Python 3.7
  • The output of pip freeze:
argcomplete==1.11.1
blis==0.4.1
boto3==1.14.0
botocore==1.17.0
CacheControl==0.12.6
cachetools==4.1.0
catalogue==1.0.0
certifi==2020.4.5.2
cfn-flip==1.2.3
chardet==3.0.4
click==7.1.2
cymem==2.0.3
docutils==0.15.2
durationpy==0.5
fasttext==0.9.2
firebase-admin==4.3.0
Flask==0.12.2
future==0.18.2
google-api-core==1.20.0
google-api-python-client==1.9.2
google-auth==1.16.1
google-auth-httplib2==0.0.3
google-cloud-core==1.3.0
google-cloud-firestore==1.7.0
google-cloud-storage==1.28.1
google-resumable-media==0.5.1
googleapis-common-protos==1.52.0
grpcio==1.29.0
gunicorn==20.0.4
hjson==3.0.1
httplib2==0.18.1
idna==2.9
importlib-metadata==1.6.1
itsdangerous==1.1.0
Jinja2==2.11.2
jmespath==0.10.0
kappa==0.6.0
MarkupSafe==1.1.1
msgpack==1.0.0
murmurhash==1.0.2
numpy==1.18.5
pandas==1.0.4
pip-tools==5.2.1
plac==1.1.3
placebo==0.9.0
preshed==3.0.2
protobuf==3.12.2
pt-core-news-sm==2.2.5
pyasn1==0.4.8
pyasn1-modules==0.2.8
pybind11==2.5.0
python-dateutil==2.6.1
python-slugify==4.0.0
pytz==2020.1
PyYAML==5.3.1
requests==2.23.0
rsa==4.0
s3transfer==0.3.3
six==1.15.0
spacy==2.2.4
srsly==1.0.2
text-unidecode==1.3
thinc==7.4.0
toml==0.10.1
tqdm==4.46.1
troposphere==2.6.1
uritemplate==3.0.1
urllib3==1.25.9
wasabi==0.6.0
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.51.0
zipp==3.1.0
  • Your zappa_settings.json:
{
    "dev": {
        "app_function": "app.app",
        "profile_name": "default",
        "project_name": "default",
        "runtime": "python3.7",
        "s3_bucket": "XXXXX",
        "aws_region": "sa-east-1",
        "slim_handler": true,
        "api_key_required": true


    }
}
```

As you're not using a domain name, have you added /dev to the beginning of the path of your urls?

As you're not using a domain name, have you added /dev to the beginning of the path of your urls?

Thanks for your reply.

My path is something like that:

https://XXX.execute-api.sa-east-1.amazonaws.com/dev/search

As you can see, search is the route of my Flask application.

How are you passing the API key to API gateway?

Simpler question: does it work without api_key_required?

Actually, no. I described what happens when I remove the API key:

After suspecting that the api_key_required camp could be the problem, I removed it. But instead, I got another error: "TypeError: 'NoneType' object is not callable. Now I am even more lost.

Do you have an app.py file on the same directory you have zappa_settings.json and does that file app.py define a WSGI app in the variable app? If not, your function_name needs to be changed.

@pexpert look at your cloud watch logs for the lambda function Zappa creates. This NoneType error can occur after another error. In my case, I was causing an OSError, but because of the way the error handling works, I was seeing the NoneType error in my browser.

Getting a 403 with api_key_required set to both false & true