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

Proxy problem #657

Open
xonio-x opened this issue Nov 21, 2024 · 1 comment
Open

Proxy problem #657

xonio-x opened this issue Nov 21, 2024 · 1 comment

Comments

@xonio-x
Copy link

xonio-x commented Nov 21, 2024

Hi, i try my code to running inside our internal server, after i add the proxy i got error Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential

i already double check and try the env is same and correct like my local and is running without proxy

package firebase

import (
  "context"
  "encoding/base64"
  firebase "firebase.google.com/go/v4"
  google "google.golang.org/api/option"
  "net/http"
  "net/url"

  "github.com/bytedance/sonic"

  "go.brimola.bri.co.id/libs/config"
)

type (
  Client struct {
    *firebase.App
  }
)

func NewClient(config *config.Config) (*Client, error) {
  decodedPrivateKey, err := base64.StdEncoding.DecodeString(config.Message.FCM.PrivateKey)
  if err != nil {
    return nil, err
  }

  config.Message.FCM.PrivateKey = string(decodedPrivateKey)
  serviceAccount, err := sonic.Marshal(config.Message.FCM)
  if err != nil {
    return nil, err
  }
  
  proxyURL, err := url.Parse(config.Message.FCM.Proxy)
  if err != nil {
    return nil, err
  }

  httpClient := &http.Client{
    Transport: &http.Transport{
      Proxy: http.ProxyURL(proxyURL),
    },
  }

  firebaseAdmin, err := firebase.NewApp(context.Background(), nil, google.WithHTTPClient(httpClient), google.WithCredentialsJSON(serviceAccount))
  if err != nil {
    return nil, err
  }

  return &Client{firebaseAdmin}, nil
}
@google-oss-bot
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants