Setting Up HttpClient in Effect-TS for LINE OAuth2 Verification

How I can set up the HttpClient in effect-ts/platform to perform the same operation as the curl command below?

curl -v -X POST 'https://api.line.me/oauth2/v2.1/verify' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'id_token=eyJraWQiOiIxNmUwNGQ0ZTU2NzgzYTc5MmRjYjQ2ODRkOD...' \
--data-urlencode 'client_id=1234567890'


here is my code and it get 400 bad request.

export const verifyLineIdToken = <A>(params: A) => Effect.gen(function* (_) {
    const validParams = yield* _(decodesParams(VerifyLineIdTokenRequest)(params));
    const body = new URLSearchParams();
    body.append('id_token', validParams.id_token);
    body.append('client_id', validParams.client_id);

    const req = HttpClient.request.post(LINE_VERIFY_ENDPOINT).pipe(
        HttpClient.request.setHeader('Content-Type', 'application/x-www-form-urlencoded'),
        HttpClient.request.urlParamsBody(body),
        HttpClient.client.fetchOk(),
        Effect.scoped
    );

    return yield* _(req);
});
Was this page helpful?