Error -371: Please provide SHA-256 hash of appId and app secret in Fyers API

Hello, I am passing correct parameters to generate the access token from refresh token, However I am getting following error: Error -371: Please provide SHA-256 hash of appId and app secret.

Refresh token is generated today. Within 2 minutes of refresh token generation, I wan trying to use refresh token to generate new access token. (to test my code)

Please help solve this query as I am unable to use the APIs for trading. Especially after cloudflare update.

Here is my code:

import requests
import hashlib

url = 'https://api-t1.fyers.in/api/v3/validate-refresh-token'
headers = {'Content-Type': 'application/json'}

app_id = "B********Z-100"
secret_key = "B********J"

input_string = f"{app_id}:{secret_key}"
sha256_hash = hashlib.sha256(input_string.encode()).hexdigest()

data = {
    'pin': '****',
    'appIdHash': '{sha256_hash}',
    'grant_type': 'refresh_token',
    'refresh_token': 'ey**********Q',
}

response = requests.post(url, headers=headers, json=data)

print(response.text)

3 replies