https://supertokens.com/ logo
a

alisha

05/30/2022, 8:01 AM
hey, I am trying to add additional key value pairs in the request body of Signinup POST API, but when I try to print the body, I see that the body is empty
r

rp

05/30/2022, 8:03 AM
hey @alisha
can you show me the request you are making? And what you are printing out?
a

alisha

05/30/2022, 8:03 AM
Copy code
{
  "code": "code",
  "thirdPartyId": "google",
  "redirectURI": "http://localhost:3000/auth/callback/google",
  "firstName": "abc"
}
Copy code
APIs: func(originalImplementation tpepmodels.APIInterface) tpepmodels.APIInterface {
                        // First we copy the original implementation
                        originalThirdPartySignInUpPOST := *originalImplementation.ThirdPartySignInUpPOST

                        // we override the thirdpartyemailpassword signinup POST API to return the social provider's access token
                        (*originalImplementation.ThirdPartySignInUpPOST) = func(provider tpmodels.TypeProvider, code string, authCodeResponse interface{}, redirectURI string, options tpmodels.APIOptions, userContext supertokens.UserContext) (tpepmodels.ThirdPartyOutput, error) {

                            body := options.Req.Body

                            strBody, err := ioutil.ReadAll(body)
                            if err != nil {
                                fmt.Println("err in printing body", err)
                            }
                            fmt.Printf("strBody??? %s", strBody)

                            // first we call the original implementation
                            resp, err := originalThirdPartySignInUpPOST(provider, code, authCodeResponse, redirectURI, options, userContext)
                            if err != nil {
                                return tpepmodels.ThirdPartyOutput{}, err
                            }
Copy code
bodyyyyyyy {0xc00071e080 0xc00011e240}
strBody???
r

rp

05/30/2022, 8:09 AM
hmm. So i think what's happening is that our API logic is already reading the body once before calling your override function. So if you read the stream again, it will be empty
Can you open an issue about this on our github? We will fix this!
a

alisha

05/30/2022, 8:10 AM
sure will do thanks
r

rp

05/30/2022, 8:29 AM
thanks
4 Views