I am working to extract data using linkedin api

I am writing script for extracting data using linkedin_api . However while authenticating the app it redirects me to localhost.

import requests
import random
import json
import string
import webbrowser

def read_credentials(filename):
    """"Reads the credentials and return the clientID and password"""
    try:
        with open(filename) as f:
            credentials = json.load(f)
        return credentials
    except FileNotFoundError:
        print(f'Error:{filename} not found')
        return None
    

def create_CSRF_token():
    """Protects against cross site request forgery"""
    letters = string.ascii_lowercase
    tokens = ''.join(random.choice(letters) for i in range(20))
    return tokens


api_url = 'https://www.linkedin.com/oauth/v2'

def authorize(api_url,client_id,client_secret,client_uri):
    """
    Make a HTTP request to the authorization URL.
    It will open the authentication URL.
    Once authorized, it'll redirect to the redirect URI given.
    The page will look like an error. but it is not.
    You'll need to copy the redirected URL.
    """

    # Request authentication url
    csrf_token = create_CSRF_token()
    params = {
        'response_type' : 'code',
        'client_id' : client_id,
        'redirect_uri': client_uri,
        'state': csrf_token,
        'scope': 'r_liteprofile,r_emailaddress,w_member_social'
    }

    response = requests.get(f'{api_url}/authorization',params=params)
    authorization_url = response.url

    print(f'''
    The authorization url is {authorization_url}      
    The Browser will open to ask you to authorize the credentials.n
    Since we have not set up a server, you will get the error:n
    This site can’t be reached. localhost refused to connect.n
    This is normal.n
    You need to copy the URL where you are being redirected to.n
    ''')

    open_url(response.url)

    # Get the authorization verifier code from the callback url
    redirect_response = input('Paste the full redirect URL here:')
    auth_code = parse_redirect_uri(redirect_response)
    return auth_code

def open_url(url):
    '''
    Function to Open URL.
    Used to open the authorization link
    '''
    print(url)
    webbrowser.open(url)

def parse_redirect_uri(redirect_response):
    """Parse redirect responses into components.
    Extract the authorized tokens from redirect uri"""
    from urllib.parse import urlparse, parse_qs

    url = urlparse(redirect_response)
    query_params = parse_qs(url.query)
    if 'code' in query_params:
        return query_params['code'][0]
    else:
        print("Authorization code not found in redirect URL")
        return None

def save_token(filename,data):
    """
    Write tokens to credentials file
    """
    data = json.dumps(data, indent=4)
    with open(filename,'w') as f:
        f.write(data)


def headers(access_token):
    """
    Make the headers to attach to the API call 
    """
    headers = {
        'authorization':f'Bearer{access_token}',
        'cache-control': 'no-cache',
        'X-Restli-Protocol-Version': '2.0.0'
    }
    return headers

def refresh_token(auth_code,client_id,client_secret,client_uri):
    '''
    Exchange a Refresh Token for a New Access Token.
    '''
    access_token_url = 'https://www.linkedin.com/oauth/v2/accessToken'

    data = {
        'grant_type': 'authorization_code',
        'code': auth_code,
        'redirect_uri': client_uri,
        'client_id': client_id,
        'client_secret': client_secret
        }

    response = requests.post(access_token_url, data=data, timeout=30)
    response = response.json()
    print(response)
    access_token = response.get('access_token')
    if access_token is None:
        print('Access token not found in response data')
    return access_token


def auth(credentials):
    '''
    Run the Authentication.
    If the access token exists, it will use it to skip browser auth.
    If not, it will open the browser for you to authenticate.
    You will have to manually paste the redirect URI in the prompt.
    '''
    creds = read_credentials(credentials)
    #print(creds)
    client_id, client_secret = creds['client_id'], creds['client_secret']
    redirect_uri = creds['redirect_uri']
    api_url = 'https://www.linkedin.com/oauth/v2' 
        
    if 'access_token' not in creds.keys(): 
        args = client_id,client_secret,redirect_uri
        auth_code = authorize(api_url,*args)
        access_token = refresh_token(auth_code,*args)
        creds.update({'access_token':access_token})
        save_token(credentials,creds)
    else: 
        access_token = creds['access_token']
    return access_token



if __name__ == '__main__':
    credentials = 'credentials.json'
    access_token = auth(credentials)

I am using the above code for authentication

Authorization code not found in redirect URL
{'error': 'invalid_request', 'error_description': 'A required parameter "code" is missing'}
Access token not found in response data

This is the output I am getting after running the code.
I have already checked for my credentials in json file, they match with the values on Linkedin developer portal.
What could be potential issue here ?

Authenticate the linkedin api. Expecting the access token to be generated after running the script.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật