Skip to content

How to implement an authenticator which needs to do to a request #197

Closed Answered by Sammyjo20
Sparclex asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Sparclex really sorry about missing this!

I've had situations where I've had to do the same thing. The best solution I've found so far is using Saloon's boot method on the connector to make another request before the real request gets sent. Additionally, you could clean up this logic into an invokable middleware class and use that middleware in here too.

public function boot(PendingRequest $pendingRequest)
{
     // Let's first return early if the connector is about to make the same request.
     // we don't want an infinite loop on our hands!

     if ($pendingRequest->getRequest() instanceof AuthenticationRequest) {
          return; 
     }

     // Check if we already have valid …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Sparclex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants