Skip to content

Golang Braintree Http Client Issue on Google App Engine

Hi Folks,

Recently I facing an issue when I implement braintree sdk for golang. The issue is on http client that blocked by google app engine.

Braintree is not providing (yet) official SDK for Golang. Gratefully someone has made it perfectly available for us ( https://github.com/lionelbarrow/braintree-go).

When I tried it on my local machine it’s working perfectly. But when I run it on app engine system, I got error :

“Unable to generate client token : Post https://api.sandbox.braintreegateway.com:443/merchants/xxxxx/client_token: http.DefaultTransport and http.DefaultClient are not available in App Engine. See https://cloud.google.com/appengine/docs/go/urlfetch/”

Its caused because app engine does not allowing us to perform outbound request directly using native http client, everything should be passed over urlfetch.

Someone before me has facing same issue, and here we go :

https://github.com/lionelbarrow/braintree-go/issues/49

The creator was added new function called NewWithHttpClient that allowing us to create custom http client that used by the SDK. Below the implementation :

This is normal implementation using standard http client :

And this is the solution for app engine, we use custom http client :

Now, it’s working perfectly under app engine ecosystem.

 

 

 

It's only fair to share...Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0
Published inApp EngineGCPGolangProgramming

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *


8 − four =