ttrodd
(Tim Trodd)
March 2, 2020, 10:58am
1
Matrix Version: 5.5.3.0
Hello,
I am currently testing out an API of a system we would like to use in the future.
To grab the token (bearer), we use a post request with this in the body(x-www-form-urlencoded) :
username:xxx
password:xxx
grant_type:password
With the post to a url www.abc.com/token
This supplies us back with a token which is valid for 24hs.
Using postman I can easily do the above. Is there anything in matrix to be able to:
a) retrieve the token with just the above details?
b) refresh the token every 24 hours automatically?
Cheers,
Tim
ttrodd
(Tim Trodd)
March 2, 2020, 11:12am
2
I suppose I could retrieve the token using another REST resourse asset, then grab the contents of that asset within the other rest asset. Not sure if there is a better way?
ttrodd
(Tim Trodd)
March 2, 2020, 11:24am
3
Ignore this thread. I did the above:
REST asset to retrieve the token.
used the js area in the REST to grab the token value and print it to the page
used %globals_asset_contents_raw:xxx% in the other REST asset that actually grabs the real content in the post body.
seems to all work ok and grabs a new token each time which also solves my part b in the original post.
Cheers
Tim
tbaatar
(Tbaatar)
March 2, 2020, 10:03pm
4
Might want to edit the xxx dot com link. Not work friendly at all
1 Like
ttrodd
(Tim Trodd)
March 2, 2020, 10:15pm
5
Hahah definitely didn’t think that one through! Changed it!
Bart
(Bart Banda)
March 3, 2020, 10:22am
6
What API are you connecting to? Is it OAuth2 based at all? Could you use the OAuth2 or other OAuth token assets to manage the token refresh for you?
haha