Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to specify the API key to use on a per-call or per-endpoint basis? #163

Closed
toolness opened this issue Apr 26, 2020 · 2 comments

Comments

@toolness
Copy link

Hello, on my development and staging servers I'm using my publishable API key from production to make US Verification requests (so that they're "real" without actually affecting the real world in any way), while I'm using my secret API key from testing to make Letter requests (so that they don't actually affect the real world).

The only ways I've found to do this are to either subclass the related Resource classes in a way that feels invasive, or to change the value of lob.api_key to its appropriate value before making the request (paying attention to thread safety since it's a global variable). I currently use the latter strategy, but both of these mechanisms feel suboptimal, and I'm curious if there's some other way to do this that I've missed, or if you'd accept PRs to make it easier to do this.

@ShariqT
Copy link
Contributor

ShariqT commented Nov 3, 2021

First off, thanks for using Lob and for highlighting this issue for us. What you are looking to accomplish makes perfect sense as testing with address verification can use a Live key while you’d want to use a Test key for Print & Mail testing.

Apologies this issue went so long unanswered. We are currently working on a PR to add this functionality.

@ShariqT
Copy link
Contributor

ShariqT commented Jan 26, 2022

@toolness We got the functionality you requested in the latest version of lob-python (v4.5.2). Each method call has an optional parameter called api_key that you can pass in a different key if you want.

@ShariqT ShariqT closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants