Skip to main content
Version: 1.0.0

Get Server Token

POST 

/authentication/serverAuthToken

Username : App Key, Password : App Secret. These will shared by GTN.

A signed JWT token is used to get the access token to the open API services.

FinTech public key - need to generate as mentioned here

FinTech private key - need to generate as mentioned here

Assertion - This is a JWT token that will be generated from the client-server side and sent as a request parameter. This will be generated using, Fintech private key, institution app key and claims - institution code as instCode and server id as userId.

When generating JWT from the server side, you need to add the institution code and server id/ user id as claims.

INST_CODE : FinTech institution code is given by GTN

USER_ID : FinTech backend service's instance unique id

Recommend to use 1 server token over using multiple server tokens.

String INST_CODE = "instCode";
String USER_ID = "userId";

Map<String, String> payload = new HashMap<>();
payload.put(INST_CODE, instCode);
payload.put(USER_ID, userId);

Code Sample-

   public static Algorithm getAlgorithm(String publicKey, String privateKey){
return Algorithm.RSA256(getPublicKey(publicKey), getPrivateKey(privateKey));
}
private static RSAPrivateKey getPrivateKey(String privateKeyString){
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
byte[] pvtKeyBytes = base16Decoder(privateKeyString);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pvtKeyBytes);
return (RSAPrivateKey) kf.generatePrivate(keySpec);
} catch (Exception e){
...
}
return null;
}


private static java.security.interfaces.RSAPublicKey getPublicKey(String publicKeyString){
byte[] pubKeyBytes = base16Decoder(publicKeyString);
try{
KeyFactory kf = KeyFactory.getInstance("RSA");
RSAPublicKey pkcs1PublicKey = RSAPublicKey.getInstance(pubKeyBytes);
BigInteger modulus = pkcs1PublicKey.getModulus();
BigInteger publicExponent = pkcs1PublicKey.getPublicExponent();
RSAPublicKeySpec keySpec = new RSAPublicKeySpec(modulus, publicExponent);
return (java.security.interfaces.RSAPublicKey) kf.generatePublic(keySpec);
} catch (IllegalArgumentException ie) {
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(pubKeyBytes);
return (java.security.interfaces.RSAPublicKey) kf.generatePublic(keySpec);
} catch (Exception e) {
...
}
} catch (Exception e){
...
}
return null;
}
public static byte[] base16Decoder(final String hex) {
final byte[] bts = new byte[hex.length() / 2];
for (int i = 0; i < bts.length; ++i) {
bts[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
}
return bts;
}

long accessTokenExpiryTimeMs = 123123123234L;
Date accessTokenExpiry = (new Date(System.currentTimeMillis() + accessTokenExpiryTimeMs));

Algorithm algorithm= getAlgorithm(publicKey, privateKey);



String assertion = JWT.create()
.withIssuer(APP_KEY)
.withPayload(payload)
.withExpiresAt(accessTokenExpiry)
.withIssuedAt(new Date())
.withNotBefore(new Date())
.sign(algorithm);

Request

Body

    assertion stringrequired

    signed JWT token at client side using institution code and user id in the payload

Responses

OK

Schema
    status stringrequired

    Possible values: [SUCCESS, FAILED]

    reason string
    rejectCode integer

    Find error codes here)

    accessToken stringrequired
    refreshToken stringrequired
    accessTokenExpiresIn integerdeprecated

    UTC time

    accessTokenExpiresAt integerrequired

    UTC time

    refreshTokenExpiresIn integerdeprecated

    UTC time

    refreshTokenExpiresAt integerrequired

    UTC time

    tokenType stringrequired

    Example: bearer

Loading...
Is this page helpful for you?