node.jshttp-redirectoauth-2.0tiktok

TIKTOK LoginKit, redirect_uri bad



     @Get('/tiktok/redirect')
        loginTicTok(
            @Res() res,
        ) {
            const csrfState = Math.random().toString(36).substring(2);
            res.cookie('csrfState', csrfState, { maxAge: 60000 });
            let url =`${this.config.get('tictokURL')}`;
            url +=`?client_key=${this.config.get('tictokClientKey')}`;
            url +=`&scope=video.upload`;
            url += '&response_type=code';
            url += '&redirect_uri=https://reelcrm-backend.herokuapp.com/social-network/tiktok/';
            res.redirect(url);
        }

https://www.tiktok.com/v2/auth/authorize/?client_key=myclientcode&scope=video.upload&response_type=code&redirect_uri=https://reelcrm-backend.herokuapp.com/social-network/tiktok/

enter image description here


Solution

  • I think your TikTok request URL is right https://www.tiktok.com/v2/auth/authorize/?client_key=myclientcode&scope=video.upload&response_type=code&redirect_uri=https://reelcrm-backend.herokuapp.com/social-network/tiktok/.

    And I also your redirect uri is same but you need to encode your URL parameters tiktok guideline for URL encode parameters.

    so try using encoded URL query params this is reference https://developers.tiktok.com/doc/login-kit-web