Django – Redirection to Strava API Auth Page is not working

So I’m Trying to redirect my django web app after the user submitted the form AND if the user chose ‘Strava Link’ Option from the form.

What I’m currently doing is to open Strava’s API Authorization Page for code/token exchange so my app will fetch the data from user’s Strava account.

My current problem is that it does not redirect to my Strava API’s Authorization page (No Error, nothing) and I tried printing the Authorization URL so I can debug it. I Tried Manually opening the Authorization URL and It is working.

I’ve watched some Strava API tutorials using python and all of them manually enters the link to copy the code after the user clicked ‘Authorized’.

Is My method correct?

Form Submission -> Redirect the user to Strava’s API Authorization
Page (stuck on this step) -> Callback to return the code/token ->
Fetch the data

Here’s my current code innside views.py:

async def index(request):
    if request.method == 'POST': #Start of process after Form Submitted
        try:
            data_dict = link_validation(request, data_dict) 
            #Rest of the code Here (Irrelevant and not related to Strava API)
        except Exception as e:
            return render(request, 'index.html', {'error_message': str(e)})
    else:
        return render(request, 'index.html')
        

def link_validation(request, data_dict):
    redirect_to_strava_auth(request)
    #Rest of the code logic here to be put when Strava API Authorization is solved

def redirect_to_strava_auth(request):
    auth_url = f"https://www.strava.com/oauth/authorize?client_id={STRAVA_CLIENT_ID}&response_type=code&redirect_uri={REDIRECT_URI}&approval_prompt=force&scope=read,profile:read_all,activity:read"
    print("Redirect URL:", auth_url) #Prints a valid link and I tried opening it in browser manually, it works
    return redirect(auth_url) #This is the problem I can't solve (Not producing any error, just no redirection) 
    
#This function will be executed right after the user clicked the 'Authorize' on my Strava API
def exchange_code_for_token(request):
    code = request.GET.get('code')
    
    token_url = "https://www.strava.com/oauth/token"
    payload = {
        'client_id': STRAVA_CLIENT_ID,
        'client_secret': STRAVA_CLIENT_SECRET,
        'code': code,
        'grant_type': 'authorization_code'
    }
    response = requests.post(token_url, data=payload)
    if response.status_code == 200:
        access_token = response.json()['access_token']
        # Save access_token to the user session or database
        return HttpResponseRedirect('/index/')  # Redirect to success page or any other page
    else:
        return HttpResponse("Error exchanging code for access token")

Here’s my current Strava API Settings:

enter image description here

Here’s the current step by step demo of my current progress on youtube video
(Ignore the error message that appeared in card as it is not related to API Redirection).

YOUTUBE: django strava API redirection to auth page not working

Alternative Solution Idea (In case my method won’t really work) – Via JavaScript:

Conditional Check on javascript if auth code already exists -> Put the
Authorization Page as <a href = ""> on Form -> User manually clicks
the link -> User Authorizes my API -> Redirect back to my django app
along with Auth Code/Token and store it in session -> Pass the code when form is submitted to views.py