hey, I am trying to add additional key value pairs...
# support-questions
a
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
hey @alisha
can you show me the request you are making? And what you are printing out?
a
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
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
sure will do thanks
r
thanks
4 Views