google-api-go-client icon indicating copy to clipboard operation
google-api-go-client copied to clipboard

Ability to access firebase auth emulator with identitytoolkit

Open anuraaga opened this issue 1 month ago • 0 comments

Is your feature request related to a problem? Please describe.

I would like to unit test some code using identitytoolkit to create tenants against the Firebase auth emulator, but currently it doesn't seem to be possible. The emulator exposes identitytoolkit at URLs such as

http://localhost:60304/identitytoolkit.googleapis.com/v2/projects/test/tenants

If I try to initialize identity toolkit with this endpoint,

gcpIdentity, err := identitytoolkit.NewService(ctx, option.WithEndpoint("https://localhost:60304/identitytoolkit.googleapis.com"))

it still sends requests to /v2, not to /identitytoolkit.googleapis.com/v2. This is because any path components from endpoint are stripped all the time.

https://github.com/googleapis/google-api-go-client/blob/main/identitytoolkit/v2/identitytoolkit-gen.go#L6186 https://github.com/googleapis/google-api-go-client/blob/711eb913fe455ffe5c9d717b44762801820c0e8c/googleapi/googleapi.go#L302

Describe the solution you'd like A clear and concise description of what you want to happen.

I'm not too sure the motivation of stripping paths opaquely since all default endpoints should be valid without stripping, and otherwise the user is providing a value that seems like it should be respected. So the simplest would be to not strip out path from endpoint.

If it's a breaking change, then perhaps an option to force keeping the path.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Natively handling the same env var FIREBASE_AUTH_EMULATOR_HOST as the firebase admin SDK. But as this is generated code, it seems not reasonable to have identitytoolkit-specific logic in it.

Additional context Add any other context or screenshots about the feature request here.

anuraaga avatar Jul 03 '24 06:07 anuraaga