braintree / braintree_python

Braintree Python library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
242 stars 115 forks source link

Making API calls using different sets of credentials. #69

Closed tjratch closed 8 years ago

tjratch commented 8 years ago

Hi There,

We're a third party metrics provider for Braintree need to make API calls with a different set of credentials depending on the company we are working with. However, from using the API it's only possible to specify credentials globally when you first configure the Braintree module (e.g. braintree.Configuration.configure) and cannot specify them on a per API call basis. This is problematic because API calls are no longer thread safe because the global configuration could changed before making an API request.

From looking at configuration.py I could create my own wrapper class and call gateway() directly, but this will require me to wrap a lot of methods this way. Would it be possible to specify a way to specify API credentials on a per call basis OR make an encapsulated object instead of specifying the credentials globally?

pblesi commented 8 years ago

Hi @tjratch, You can accomplish this by instantiating your own Configuration and then instantiating your own BraintreeGateway in order to make your API calls.

I am going to close this issue for now. Please reopen it if you have further issues.

tjratch commented 8 years ago

Thanks for the response @pblesi! In the end, that's what I ended up doing in the end. I'm super crazy about this solution because it will be a bit confusing to the other developers on the team because it doesn't line up with any of the documentation.

Either way, thanks for the help!