Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Making my Django Endpoint Restricted so that only I can access it

I'm very new to websites.

I'm trying to process payments using Stripe in a JS file, and this file is static meaning it is public. I'm trying to take the part that makes an API request with a secret key and move it to the backend and then call the backend to receive the response that comes from using the secret key.

However, currently any person is able to make the request, which defeats the purpose of what I am doing.

def payment(request):
    return render(request, 'interface/about.html')

    def get(self, request, *args, **kwargs):
        return(HttpResponse("laterthere"))

urls.py

    path('payment', views.payment, name="payment")

JS:

var resp1 = await fetch('https://url.com/payment', {
            method: 'GET'
        });

Is there any way to do this? If suggesting a better direction to go in please do provide resources.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to add authentication to your API. This way you can assign permissions to users so that only they can access certain login. As an example, imagine you build your User model, to have a is_admin property (which is default by django). Then you can check if the user is an admin.

def get(self, request, *args, **kwargs):
    if request.user.is_admin:
        return(HttpResponse("laterthere"))
    else:
        raise AuthenticationError

Here is more information for DRF https://www.django-rest-framework.org/api-guide/authentication/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!