func downloadContentWithRetry(downloadURL string, numberOfRetries, waitInterval uint) ([]byte, error) {
	var contentBytes []byte
	return contentBytes, retry.Times(numberOfRetries).Wait(time.Duration(waitInterval) * time.Second).Try(func(attempt uint) error {
		var err error
		contentBytes, err = downloadContent(downloadURL)
		return err
	})
}
downloadContentWithRetry calls downloadContent method with a given number of retries and waiting interval between the retries.
package main
import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
	"time"
	"github.com/bitrise-io/go-utils/fileutil"
	"github.com/bitrise-io/go-utils/log"
	"github.com/bitrise-io/go-utils/retry"
	"golang.org/x/oauth2/google"
	"golang.org/x/oauth2/jwt"
	"google.golang.org/api/androidpublisher/v3"
)
func createHTTPClient(jsonKeyPth string) (*http.Client, error) {
	jsonKeyPth, isRemote, err := parseURI(string(jsonKeyPth))
	if err != nil {
		return nil, fmt.Errorf("failed to prepare key path (%s), error: %s", jsonKeyPth, err)
	}
	var authConfig *jwt.Config
	var authConfErr error
	if isRemote {
		jsonContent, err := downloadContentWithRetry(jsonKeyPth, 3, 3)
		if err != nil {
			return nil, fmt.Errorf("failed to download json key file, error: %s", err)
		}
		authConfig, authConfErr = google.JWTConfigFromJSON(jsonContent, androidpublisher.AndroidpublisherScope)
		if authConfErr != nil {
			return nil, err
		}
	} else {
		authConfig, authConfErr = jwtConfigFromJSONKeyFile(jsonKeyPth)
		if authConfErr != nil {
			return nil, fmt.Errorf("failed to create auth config from json key file %v, error: %s", jsonKeyPth, err)
		}
	}
	return authConfig.Client(context.TODO()), nil
}
func jwtConfigFromJSONKeyFile(pth string) (*jwt.Config, error) {
	jsonKeyBytes, err := fileutil.ReadBytesFromFile(pth)
	if err != nil {
		return nil, err
	}
	cfg, err := google.JWTConfigFromJSON(jsonKeyBytes, androidpublisher.AndroidpublisherScope)
	if err != nil {
		return nil, err
	}
	return cfg, nil
}
func parseURI(keyURI string) (string, bool, error) {
	jsonURL, err := url.Parse(keyURI)
	if err != nil {
		return "", false, fmt.Errorf("failed to parse url (%s), error: %s", keyURI, err)
	}
	return strings.TrimPrefix(keyURI, "file://"), jsonURL.Scheme == "http" || jsonURL.Scheme == "https", nil
}