gregdevs
gregdevs

Reputation: 713

Django - accessing Django Rest endpoint on AWS Elastic Beanstalk

Very new to AWS and deploying my own projects/services in general. I deployed my first Django Rest API on Beanstalk.

I can access the application URL in the browser (http://myappenv.someid.us-west-2.elasticbeanstalk.com/, no problem.

However when I use that base url in my application on localhost, I get a 403: Authentication credentials were not provided.

I am passing the DRF Token in the header, just like I normally would to access each endpoint. ie http://myappenv.someid.us-west-2.elasticbeanstalk.com/mentions.

When I switch back to a local version of the API in my application, I can access it normally. My application is hitting the endpoint but, for some reason, even with the token passing, its returning the 403

my DRF is setup in settings.py as follows:

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
    ),
        'DEFAULT_AUTHENTICATION_CLASSES': (
        #'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication'

    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ) ,
   'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)           

}

Any ideas? Would appreciate any feedback.

Upvotes: 1

Views: 861

Answers (1)

gregdevs
gregdevs

Reputation: 713

After going through the DRF documentation, I have to adjust my DEFAULT_PERMISSION_CLASSES

Upvotes: 1

Related Questions