API authentication using AWS signature version 4 with Laravel 8

Viewed 304

I have a client that uses the orderhive service as an inventory management system, So I do not understand the auth with Laravel 8. What I understood from this link orderhive API docs is that I will get two tokens from the client app_token and refresh_token, then I should send them somewhere / somehow to AWS to get a bunch of tokens then send the request.

I do not understand that process altogether, and I hope there is any package or something built in Laravel to ease that process. Like if the AWS SDK itself could be easier to integrate. All tutorials and lessons are about S3 images, so any info would be appreciated.

1 Answers

The process of dealing with such a scenario is as follows:

  • you will have all the app credentials
  • use the credentials to grant access (code grant - JWT) as an example
  • after you grant the access you shall have (access_token)
  • the access token will be valid for a certain time (e.g. 8hours)
  • use the access token to generate a (refresh_token)
  • store the access_token and the refresh_token and date_generated somewhere
  • whenever you want to make a call to the API just use the stored tokens
  • if the access_token expired, use the refresh_token to regenerate a new access_token
  • when generating a new access_token via the refresh_token, the response should contain a new access_token and new refresh_token
  • replace the new tokens with the old ones

feel free to ask if any point was not clear for you.

Related