Even after posting grant_type as "refresh_token" api call is returning 401

Please find the below code and let me know what is that causing 401.

Response: {'s': 'error', 'code': -442, 'message': 'Please provide valid grant_type'}

    url = 'https://api-t1.fyers.in/api/v3/validate-refresh-token'
    headers = {
        'Content-Type': 'application/json'
    }
    data = {}
    data['grant_type'] = "refresh_token"
    data['appIdHash'] = "***"
    data['refresh_token'] = "my_refresh_token_here"
    data['pin'] = "***"

    response = requests.post(url, headers=headers, json=json.dumps(data, indent=4))
    
    if response.status_code != 200:
        print(response.json())
        print(response.json()["message"])
    else:
        print(response.json()['access_token'])
1
3 replies