[missing]identityProviderId Error
-
So I was implementing a custom google login flow following along with the Docs (https://fusionauth.io/docs/v1/tech/apis/identity-providers/google). So my client app has a google auth button and it basically triggers the pop up and the user signs up/logs in. This is not related to FusionAuth yet until I send the id_token from that successful login , which I successfully received and logged, to the /api/identity-provider/login endpoint as stated in the docs. In my POST request, I include all the required information including the id_token, applicationId, and the identityProviderId for Google straight from the docs and my provider instance in my FusionAuth dashboard as you can see below.
fetch("http://localhost:9011/api/identity-provider/login", { method: "POST", body: JSON.stringify({ data: { token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", }, identityProviderId: "82339786-3dff-42a6-aac6-1f1ceecb6c46", applicationId: "XXXXXXXXXXXXXXXX", }), }) .then((res) => res.json()) .then((result) => console.log(result)) .catch((err) => { console.log(err); });
For some reason when I run this from my browser which is CORS enabled and my Fusion Auth application also has Google Provider enabled I get the below error. I have no idea what the actual problem is since I clearly have the identityProviderId listed exactly as how it was stated in the docs. If i remove all the other information from the request I still get the same error. What is very weird is that when I make this exact same request from Postman desktop, it works perfectly and I get back the expected response. What could be the problem here, and why am I getting such an unrelated error which makes it virtually impossible to debug?
{ "fieldErrors": { "identityProviderId": [ { "code": "[missing]identityProviderId", "message": "You must specify the [identityProviderId] property." } ] } }
Pulled over from https://github.com/FusionAuth/fusionauth-issues/issues/875
-
Try adding
mode: 'no-cors'
to your request to see if that changes your result.Also, make sure that
application/json
is theContent-Type
header for all requests to the FusionAuth API, unless otherwise specified in the documentation.Narrator: This resolved the issue.