Andrew Chow
Andrew Chow

Reputation: 33

Tiktok OAuth v2 request parameters are malformed

Trying to migrate from Tiktok's API from v1 to v2 endpoints. Currently version 1 works for me but my request to the https://open.tiktokapis.com/v2/oauth/token/ endpoint keeps returning

{
    "error": "invalid_request",
    "error_description": "The request parameters are malformed.",
    "log_id": "202308141814065FE27A58513347021AF1"
}

I'm testing this through Postman and here are screenshots of my request: enter image description here

enter image description here

The url used to obtain the "code" passed into the postman request is https://www.tiktok.com/v2/auth/authorize/?client_key=abcdefg&scope=user.info.basic,user.info.profile,user.info.stats,video.list&response_type=code&state=abcdefg&redirect_uri=https://www.test.com/redirect

I've requested support from Tiktok for the log_id and they say its due to "grant type is not set in request." I'm using applicaiton/x-www-form-urlencoded in Postman's header so if that is the issue I'm not sure what else to modify.

Upvotes: 0

Views: 1491

Answers (1)

Karine Valença
Karine Valença

Reputation: 131

I think your issue is because you're passing the params in the query params, they must be in the body params: enter image description here

you can also try to import this curl in the postman, it's in the official documentation:

curl --location --request POST 'https://open.tiktokapis.com/v2/oauth/token/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cache-Control: no-cache' \
--data-urlencode 'client_key=CLIENT_KEY' \
--data-urlencode 'client_secret=CLIENT_SECRET' \
--data-urlencode 'code=CODE' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=REDIRECT_URI'

reference: https://developers.tiktok.com/doc/oauth-user-access-token-management

Upvotes: 3

Related Questions