API to get new token against refresh token

Hi,

When a user logs in, we get a token and a refresh token. We want to implement the functionality of the refresh token where the main token has expired and we generate a new token by calling some API with the refresh token.

{
    "token": "eyJhbGciOiJSUzUxMiJ9....",
    "expiresIn": 1800,
    "refreshToken": "eyJhbGciOiJSUzUx....",    // How to use this to get a new `token`?
    "refreshExpiresIn": 432000
}

I could not find the API for this thing. What is the correct API endpoint/request where I can get the new token with the refresh token?

Thanks,
Ayush

Hi @ayush,

Use the below endpoint to generate access token from the refresh token.

API Endpoint: /v1/auth/generate/access-token

Request:

{
“refreshToken”: “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c”
}

Thanks
Deepak

3 Likes

Hi @depakpant,

The API you provided is giving out HTML response when I tried. Can you please check and help me rectify if there is some mistake in my request? I tried adding Bearer prefix too but got same response,

Also less confirm if the complete URL is correct

https://healthidsbx.abdm.gov.in/v1/auth/generate/access-token

Request

curl --location --request POST 'https://healthidsbx.abdm.gov.in/v1/auth/generate/access-token' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJBbFJiNVdDbThUbTlFSl9JZk85ejA2ajlvQ3Y1MXBLS0ZrbkdiX1RCdkswIn0.eyJleHAiOjE2NDU1OTc5MTYsImlhdCI6MTY0NTU5NzMxNiwianRpIjoiM2I3NWMxN2UtZWFmYi00Yjk5LThmZjMtOWE0MDhhNmViZWI3IiwiaXNzIjoiaHR0cHM6Ly9kZXYubmRobS5nb3YuaW4vYXV0aC9yZWFsbXMvY2VudHJhbC1yZWdpc3RyeSIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiJmMDJiMTYwNy00YTZiLTRmOTctYWJmMS1iYTRiNzg1YjBiMjgiLCJ0eXAiOiJCZWFyZXIiLC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MENioKFdkDwCgjAV1Q' \
--header 'X-HIP-ID: SBX_000324' \
--header 'Content-Type: application/json' \
--data-raw '{
    "refreshToken": "eyJhbGciOiJSUzUxMiJ9.eyJzdWIiOiI0Ni0wMjA1LTg1NTYtNjgxNyIsImNsaWVudElkIjoiU0JYXzAwMDMyNCIsInR5cCI6IlJlZnJlc2giLCJleHAiOjE2NDYwMjkzMjgsImlhdCI6MTY0NTU5NzMyOH0.A0I78pBhjqQy2WoqTFZ_0RePNtaOopyceJMgV1bA5t_l4y8QO-t_jjjO0bwCv0qnAKgV1eBDAQ5HKFldleDpWdREKx14IqWd2Xzvask8rTIG6q-CEaoNYCaFVSjqSsipsQ46XiwGOqBPgb9hN6i3Pqh8JF6tXOclUUpqD5AkAPHMkpjohrw4rUwM97k2lz50VFhDU2vRRtXTQZY6KVWnkVFjhwJs0CmF8I_wQkOo2oRGN8wptDYD0cY1qilZ5d7BDgy1-h0x5_nwXcb69keLJwog4fvFk8EcJ2YI1_SV4NS3g9cQpEVvgV5Mcoh24-e8RT76pkrP2csUxPL2nTKKE6s7hmm21KjAINHc69pyJbGhKJIfjGFHxfEpPdoaahGPiSf5r7E_-CJmBeoRX0toD6XdndBGvLwWoBVOnmh40fTd0ErBDihAQA-MzLhf74Uof7Ns7CrzAQhx7XuZVx4GPKYv4niU32SNLDJf7cy8sDzxmaH175at9qbpaicg-31mAmkOmakOTYphKZqjex2OFPEaT4_cKPK17BuC2CXTuM2CAowsf2rhQfieNMKP3ZcVxkIi1n_HXIEfThDTlzINDkMHkyoz6VGifkdBQ6quAyAbB--mUI1cRLOhahYNs0GM-fCvo2BvPdh0IeFdymcM0ZqTIKOulNNCCwQ0D-c2C2c"
}'

Response

<!doctype html>
<html lang="en">

<head>
	<meta charset="utf-8" />
	<link rel="shortcut icon" href="./favicon.ico" />
	<meta name="viewport" content="width=device-width,initial-scale=1" />
	<meta name="theme-color" content="#3a70d4" />
	<meta name="description" content="Health ID | ABDM" />
	<base href="/" />
	<link rel="manifest" href="./manifest.json" />
	<link rel="shortcut icon" href="./favicon.png" type="image/png" />
	<title>ABHA | ABDM</title>
	<link href="./static/css/2.a752b977.chunk.css" rel="stylesheet">
	<link href="./static/css/main.9797289b.chunk.css" rel="stylesheet">
</head>

<body><noscript>You need to enable JavaScript to run this app.</noscript>
	<div id="root"></div>
	<script>
		!function(e){function r(r){for(var n,l,a=r[0],f=r[1],i=r[2],c=0,s=[];c<a.length;c++)l=a[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,a=1;a<t.length;a++){var f=t[a];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="./";var a=this["webpackJsonpnhdm-sa"]=this["webpackJsonpnhdm-sa"]||[],f=a.push.bind(a);a.push=r,a=a.slice();for(var i=0;i<a.length;i++)r(a[i]);var p=f;t()}([])
	</script>
	<script src="./static/js/2.7e0604c4.chunk.js"></script>
	<script src="./static/js/main.080a4a93.chunk.js"></script>
</body>

</html>

Thanks,
Ayush

Hi @ayush,

The API is working for me.

Request:

curl -X POST “https://healthidsbx.abdm.gov.in/api/v1/auth/generate/access-token” -H “accept: /” -H “Accept-Language: en-US” -H “Authorization: Captcha_03AGdBq27wOaDEInknQ8gfiC5dMrizdPVL7JQvL7Lz6exsWps2nfXRD9W14uVZPxSjXt28ORxzm3Pcqmhc8JJI1WHBYKc5mvU69ktudWY8thyVGt5LPv96XxWI5mOQMaIxBHN9lGMc3MlAxs6DjxesM5WNe0I1yRKmmxYdQE531OKrEJVulG8LTKocAUFy06C-IGlcWm0WCM4LyXK-_4z8rWMjC9lqO8ebnRFzmk20Ab2AG_2y3P7GYj5KRVHXRTTC55WSEOQTB8xjgiFeDO-BDbciRLWdcTL2Ivxks4YCMzUOpVTk1UUDfaqfpREjziPuw0jguK0-x7VRiytwcTw_p97XdVjBWJxIhs2Cs6k_dL3oZph1Ye-Xw0ogMf7J-J7aAp3zBDp0kP8Keu2O6MKIzGgebWM6YMjHgWzNltynH0dBsJNx1EQkTVorZemBEMamtlCxpQAkf3_r2suYTq84ldp8yh4dkQauMgEowuZLl6HAyLbdskfQFGa_fFXOgMT_e5TNpM8Gs1VSwJECpz5gR8838jd_EM6_ROamXd2o1xVbnHFVJIkfZTirbg1sfeAMLyfc1oZ2mtUVxjk9Yy4IFduMTrs6pBghqDEHZfkl578PLWosBwBG5K8g2fxTqOq-kUjqV62XpKSKkHbhEhuto5s4Z7mpjXpyP8DbljZOwTfvuG643CgnQUiBVyCowSoaDFfjN1AXzpuuwE_ZTRL5krjCPKR28sjyGPhNdw_Pbmq_xGJnO1ftL0RYENxoJ0hcjDJp78uQpgj__Lc6dx9W_I9yEd6GxME5qdZzUWFklzXQ1tx7HgcaIsyEHNP7rVrrOi9sy-MlZavxvZHU6I0vJp6cMRxDIP9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kWbkvbrtyqym_Ven95pkPHKca1scGZzqGdyqikaueTfhf6R8SFnQuqYUOO02eGbbvztJFRB-kcqVyLfBTe3VWsSvXTCIXRZX2msxNwK1DvhDJCIbzY”,
“expiresIn”: 1800
}

1 Like

You are using the wrong URL.

Use this plz
https://healthidsbx.abdm.gov.in/api/v1/auth/generate/access-token

1 Like

Thanks, it worked now.

Hii
I was trying to generate access token using refresh token using api but its giving some html response with Request Rejected message.Plese let me know what if anything is wrong from my end.

Request

curl --location --request POST ‘https://dev.abdm.gov.in/api/v1/auth/generate/access-token’
–header ‘Authorization: Bearer eyJhbGciOiJSUz3Mgllp2pwBwSMu5mQncqn1Xhd_bJ9jhJTewgCjapqsJjreLW8wP-5maSrF-pKdKF6r9ADBGsWUBOhdJqoh3pCoS3l_s9loMb4Zrwxh4WyK8mGxIupJIAdKVjdV9X3zOopu_AOZMmEMxFlyHyPyNf7Rcq9YCTOcIwd3Eb_58emTzJMswvp2DGQ’
–header ‘Content-Type: application/json’
–data-raw ‘{
“refreshToken”:eyJhbGbvcjhvmkbvv5nb3YuaMiIsInNlc3Npb25fc3RhdGUiOiI3YThhYzA3My1hY2Q4LTQ3YzYtYmY5Ny05OWFkY2RiZTNkMzgiBu5czBqr-lUxU
}’

Response

<title>Request Rejected</title>
The requested URL was rejected. Please consult with your
administrator.<br><br>Your support ID is: 5170449198085157281<br><br><a href='javascript:history.back();'>[Go

    Back]</a></body>

What is the API to get refresh token for V3 Apis?

@IntegrationSupport

hey
@viewzen can u share the end point if u get the solution pls