Hi,
Im trying to pass a proxy URL into the Play integrity library, but for some 
reason the http transport which Im passing onto the client is not working 
as expected. It would be helpful if anyone can guide me in this. Thanks in 
advance.

Here is my code:
ctx := context.Background()
credentials, err := ioutil.ReadFile("../googlecredentialsfile.json")
if err != nil {
return nil, err
}

config, err := google.JWTConfigFromJSON(credentials, playintegrity.
PlayintegrityScope)
if err != nil {
return nil, err
}

var client *http.Client
if viper.GetString("ENABLE_PROXY") == "TRUE" {
// Set up an HTTP transport that uses the proxy
proxyUrl := viper.GetString("PROXY_URL")
proxy, _ := url.Parse(proxyUrl)
transport := &http.Transport{
Proxy: http.ProxyURL(proxy),
}

// Create an OAuth2 token source using the JWT config
tokenSource := config.TokenSource(ctx)

// Create a new http.Client with custom transport for proxy and OAuth2
client = &http.Client{
Transport: &oauth2.Transport{
Base: transport,
Source: tokenSource,
},
}
} else {
// No proxy, just use the default client with OAuth2
client = config.Client(ctx)
}

// Create the Play Integrity service with the HTTP client
playIntegrityService, err := playintegrity.NewService(ctx, option.
WithHTTPClient(client))
if err != nil {
return nil, err
}
.....

The traffic is not going via the proxy URL which results in getting a 
server misbehaving error from the google's library. 
Im using this library: 
https://pkg.go.dev/google.golang.org/api/playintegrity/v1 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/f995e6fa-c9e2-4395-a5e7-9b0e7c67cb99n%40googlegroups.com.

Reply via email to