Yes @Werner Stinckens​, I tried different ways to read the json file from the path where it was stored but was unable to do so. Instead of this what I have done is that I have copied the content of the JSON file in a variable and passed that to the following function

credentials = {"type":"service_account","project_id":"myapi-.................}

gc = gspread.service_account_from_dict(credentials)

So now no need to read from any json file