1

Current issue on their Github.

First, I believe the Firebase documentation for how to use AppCheck with the Golang Admin SDK is wrong here. It says you need to create a new appcheck.Client directly via method off of your firebase.App, but this method doesn't exist (anymore?).

func main() {
    app, err := firebaseAdmin.NewApp(context.Background(), nil)
    if err != nil {
        log.Fatalf("error initializing app: %v\n", err)
    }

    appCheck, err = app.AppCheck(context.Background()) // <-- here
    if err != nil {
        log.Fatalf("error initializing app: %v\n", err)
    }

    http.HandleFunc("/yourApiEndpoint", requireAppCheck(yourApiEndpointHandler))
    log.Fatal(http.ListenAndServe(":8080", nil))
}

So, instead, I've referred to Firebase's appcheck package here which says you now need to create a new instance via this method instead:

func NewClient(ctx context.Context, conf *internal.AppCheckConfig) (*Client, error)

This, in theory, should work. However, note the use of an internal module.

We can try using NewClient(...), and will be able to provide its first arg of context.Context, but won't be able to provide a value for its second arg of type *internal.AppCheckConfig because it's internal.

Does anyone have a fix for this? Or, perhaps, I'm overlooking the correct way to do this.

Thanks.

Matthew Trent
  • 2,611
  • 1
  • 17
  • 30
  • 1
    Your GitHub repro steps show your import as `"firebase.google.com/go"`, which is the `v1` version of that module. Was that also the case when you tried to use the `AppCheck` method? In the `v4` major version (which the cited Firebase documentation example uses), the [App.AppCheck](https://pkg.go.dev/firebase.google.com/go/v4#App.AppCheck) method should exist. – fizzie Jul 29 '23 at 01:02

0 Answers0