Skip to content

How to pass the base url and authentication details to the connector in non-Laravel apps? #57

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

You must be logged in to vote

Thank you for the feedback!

In my libraries/SDKs that use Saloon, I tend to define the base URL / authentication into the constructor of your SDK/Library class. Then you can create a new instance of a connector and pass it into the connector via a constructor.

For authentication, you could accept an instance of AuthenticatorInterface or create one yourself and then authenticate the connector with $connector->withAuth().

Then you can re-use the same connector multiple times for the requests.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@iamniels
Comment options

Answer selected by iamniels
Comment options

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