How can we get the access_token using th refresh_token ?

I have these two code to get the access_token

  1. Using fyers.generate_access_token()
 const fyers_access_token = await fyers.generate_access_token(reqBody)
  • Using API
const concatenatedString = process.env.FYERS_APP_ID + process.env.FYERS_SECRET_ID;
      console.log(concatenatedString);
      const hash = crypto.createHash('sha256').update(concatenatedString).digest('hex');

      const refreshToken = await fetch('https://api.fyers.in/api/v2/validate-refresh-token', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          grant_type: 'refresh_token',
          appIdHash: hash,
          refresh_token: decryptedCredentials.refresh_token,
          pin: ****
        })
      })

In step 2, I want access_token without giving a PIN. How can I do this in Javascript?

OR is there any other way to get the access_token token other than the one above?

you have to supply pin for refresh token

If you dont want to hardcode pin in the code, store it elsewhere and access it during run time.

Hey @101944335865925141850

You can get the access token from the refresh token , please find the docs for the same :

https://myapi.fyers.in/docsv3#tag/Authentication-and-Login-Flow-User-Apps/paths/~1Authentication%20&%20Login%20Flow%20-%20User%20Apps/delete

If you are looking for a way to avoid providing PIN while fetching new access token using refresh token, then it is simply not possible (considering Fyers has followed standard OAuth practice)

PIN / TOTP is mandatory to be supplied everytime while interacting with Auth servers i.e. at the time of fetching initial access token using manual browser-based auth OR even later refresh token path as per OAuth client validation standards.

You can store PIN in another safer local file & fetch it from there OR manually provide at that time to avoid security concerns.

But PIN is required Can I do without it?