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](http://res.read)()

print(data.decode("utf-8"))
  1. Replaced conn host with fyers host (conn = http.client.HTTPSConnection(“api.fyers.in”))

throwing “503 Service Temporarily Unavailable”

  1. 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.

@vikram_sri @tejas_khoday did you get any chance to look into this?

Hi Lohitha,
I have not tried the method that you have implemented,
I’ll try it out on my end and if I figure something out, I will let you know.

@vikram_sri did you get any chance to take a look?