Skip to content

Commit

Permalink
fix: OAuth response body was JSON content-type, must be form-urlencod…
Browse files Browse the repository at this point in the history
…ed as per RFC6749 (PR #1555 Fixes #1554)
  • Loading branch information
panaC committed Sep 24, 2021
1 parent 568a075 commit e8deeda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/redux/sagas/auth.ts
Expand Up @@ -283,12 +283,14 @@ async function opdsSetAuthCredentials(
}

const headers = new Headers();
headers.set("Content-Type", ContentType.Json);
headers.set("Content-Type", ContentType.FormUrlEncoded);

const body = Object.entries(payload).reduce((pv, [k,v]) => `${pv}${pv ? "&" : pv}${k}=${v}`, "");

const { data: postData } = await httpPost<IOpdsAuthenticationToken>(
authenticateUrl,
{
body: JSON.stringify(payload),
body,
headers,
},
async (res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/contentType.ts
Expand Up @@ -19,7 +19,7 @@ export enum ContentType {
Opds2Pub = "application/opds-publication+json",
Opds2AuthVendorV1_0 = "application/vnd.opds.authentication.v1.0+json",
OpenSearch = "application/opensearchdescription+xml",
FormUrlEncoded = "application/x-www-form-url-encoded",
FormUrlEncoded = "application/x-www-form-urlencoded",
Xhtml = "application/xhtml+xml",
Html = "text/html",
Epub = "application/epub+zip",
Expand Down

0 comments on commit e8deeda

Please sign in to comment.