Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

how to store a token and use it on every request as authorization Bearer

$
0
0

Hi there guys,

currently I'am busy doing integration with one of our client. They have developed a rest service web api. The request and response is in Json format. I have to create a handshake kinda session on one of the methods which response with the following below...

{"SessionKey": "W8JoSibB0S6IaUuSLq9YDM9nvEP9vmYtEmGanm3L3MY=","SessionChannelKey": "f24f5616-9906-421e-8142-359d832ad192","ResultText": "Success","ResultCode": 0
}

then i have to use the sessionkey to get the token based
response looks like this

{"AccessToken": "QxGs602C63UiDRGg2AwSEgvQw-OQ5qpS7jQoMRDfSKsrxor85k0jp9hmwtK9OvxDxy562OLeOVsJRAQEJ3MGwtgcbAGGK0mY4tRO_WXgee0Qw0LTZUnXM8UsqXFQ2NpIusbkdziPXT_RT32lMbgHR9m1wcs3JpABopojPMztV9012g0GcEfPGSclRzg38D5v9IA5JFD_0Md82dUw0rs2VjR9kuvrs_QxMY7W2SnGP9dwDLhJoQ7fDlbdqKnnTBxbsD3YqIAK5WYjz6k65jN1fwO3JQ5_FiJPGh3f2-CH5uc","AccessTokenExpiryUtc": "2018-06-07T13:05:44+02:00","RefreshToken": null,"UserId": 116,"MerchantId": 18819,"ResultCode": 0,"ResultText": "Success","TransactionReferenceNumber": null
}

Now the tricky part, is that the Token has expiry date. how can i validate the token? and where can i save the token? as this will be a automated process. Not sure if i should store it in the database? or use sessions?

help will be appreciated,

thanks

Tony


Viewing all articles
Browse latest Browse all 4850