API challenges while Generating access token with plain python

I am trying to generate access code with plain python but running into challenges (Installing 3rd party packages (fyers_api) is a challenge in my prod environment).

1. Authorization Headers (from official documentation here, https://myapi.fyers.in/docs/#operation/addpet) throwing failing an error: gaierror: [Errno 11001] getaddrinfo failed .

Code snippet :

import http.client

conn = http.client.HTTPSConnection("curl")

payload = ''

headers = {

    'Authorization': f'{api_id}:{access_token}'

    }

conn.request("GET", "/", payload, headers)

res = conn.getresponse()

data = res.read()

print(data.decode("utf-8"))

2. Replaced conn host with fyers host (conn = http.client.HTTPSConnection("api.fyers.in"))

throwing "503 Service Temporarily Unavailable"

3. Authentication & Login steps (reference: https://myapi.fyers.in/docs/#tag/Authentication-and-Login-Flow-User-Apps). Tried to convert below curl to python with postman but it is throwing "format not recognized" error.

https://api.fyers.in/api/v2/generate-authcode?client_id=sample_client_id&redirect_uri=sample_redirect_uri&response_type=code&state=sample_state

Can someone help me to get access code with plain python.

3 replies