FusionAuth / go-client

FusionAuth Go Client Library!
https://fusionauth.io/
Apache License 2.0
29 stars 32 forks source link

ResendEmailVerification(): Always getting 401 #55

Open markschmid opened 3 years ago

markschmid commented 3 years ago

Shouldn't this method use StartAnonymous()? Currently it's using an API-Key and I always run into a 401 without further information.

Checking the API manually (with a REST client) it seems that providing an API Key is the cause for the 401. Instead of API Key, the API wants an X-FusionAuth-TenantId in the header.

How to achieve that using the go-client? Can I create a client using NewClient() without an API Key and set its headers? Thanks in advance!

https://github.com/FusionAuth/go-client/blob/7e32142be8634d5ad854b5e7493a251ec3855903/pkg/fusionauth/Client.go#L2685

markschmid commented 3 years ago

I've found that using the following, it seems to work:

client := fusionauth.NewClient(httpClient, baseURL, "") // using "" as API Key
client.setTenantId = "<tenant id>"
response, errs, err := client.ResendEmailVerification(email)

Is that how to use this method? Also, it's returning EOF as err.

Any ideas / advice is appreciated.

mooreds commented 3 years ago

@markschmid do you have multiple tenants in FusionAuth? If so, you'll need to set the tenant Id using the header, or use a tenant based API key. More on that here: https://fusionauth.io/docs/v1/tech/apis/authentication/#making-an-api-request-using-a-tenant-id

It does look like we don't have a client method for anonymous sending of the email verification, though it is possible using the rest client directly. I'll file an issue.

Also, it's returning EOF as err.

I'm no golang expert, but from the code here: https://github.com/FusionAuth/go-client/blob/master/pkg/fusionauth/Client.go#L2681 It looks like errs contains any FusionAuth errors, and err contains any restclient errors (like, for example, FusionAuth being unavailable).

Any ideas / advice is appreciated.

I'm not quite clear what you are looking for, but for general support with FusionAuth, we recommend posting to the forum: https://fusionauth.io/community/forum/

markschmid commented 3 years ago

Thanks. Since the verification call succeeds, I’m just confused about the EOF err. All other client methods i’ve used so far are not returning an err when they succeed.

For now, I‘m just checking the err and consider EOF still successful.

mooreds commented 3 years ago

Thanks @markschmid . Let's leave this open so next time we take a pass though the golang client we can review.