-
Notifications
You must be signed in to change notification settings - Fork 268
fix(fcm): Add ability to override default FCM endpoint via ClientOptions #373
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @slirx for the PR. We do not want to introduce an env variable for this purpose. Ideally we should be able to use the endpoint set via options.WithEndpoint()
. This is already returned by the call to transport.NewHTTPClient()
, and is currently ignored.
I've updated it to be able to use the endpoint set via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested one change. Also require some tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @slirx. LGTM with some minor nits. I'll merge this when those points are addressed.
nil, | ||
option.WithCredentialsFile("testdata/service_account.json"), | ||
option.WithTokenSource(tokenSource), | ||
option.WithEndpoint(ts.URL), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only WithEndpoint()
should be sufficient here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gives an error only with WithEndpoint()
:
app, err := NewApp(ctx, nil, option.WithEndpoint(ts.URL))
if err != nil {
t.Fatal(err)
}
c, err := app.Messaging(ctx)
if c == nil || err != nil {
t.Fatalf("Messaging() = (%v, %v); want (iid, nil)", c, err)
}
--- FAIL: TestMessagingSendWithCustomEndpoint (0.59s)
firebase_test.go:390: Messaging() = (<nil>, project ID is required to access Firebase Cloud Messaging client); want (iid, nil)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I suppose the transport still requires some sort of a credential. In that case let's keep option.WithTokenSource()
. You definitely don't need WithCredentialsFile()
when a TokenSource is explicitly provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems WithCredentialsFile()
is required to provide project id. It gives an error without WithCredentialsFile()
:
tokenSource := &testTokenSource{AccessToken: "mock-token-from-custom"}
app, err := NewApp(
ctx,
nil,
//option.WithCredentialsFile("testdata/service_account.json"),
option.WithTokenSource(tokenSource),
option.WithEndpoint(ts.URL),
)
if err != nil {
t.Fatal(err)
}
c, err := app.Messaging(ctx)
if c == nil || err != nil {
t.Fatalf("Messaging() = (%v, %v); want (iid, nil)", c, err)
}
--- FAIL: TestMessagingSendWithCustomEndpoint (0.00s)
firebase_test.go:390: Messaging() = (<nil>, project ID is required to access Firebase Cloud Messaging client); want (iid, nil)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! :(
Fixes #189