fix: reddit token refresh fix
This commit is contained in:
@@ -14,7 +14,12 @@ const refreshToken = async ($) => {
|
|||||||
const { data } = await $.http.post(
|
const { data } = await $.http.post(
|
||||||
'https://www.reddit.com/api/v1/access_token',
|
'https://www.reddit.com/api/v1/access_token',
|
||||||
params.toString(),
|
params.toString(),
|
||||||
{ headers }
|
{
|
||||||
|
headers,
|
||||||
|
additionalProperties: {
|
||||||
|
skipAddingAuthHeader: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await $.auth.set({
|
await $.auth.set({
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ import appConfig from '../../../config/app.js';
|
|||||||
|
|
||||||
const addAuthHeader = ($, requestConfig) => {
|
const addAuthHeader = ($, requestConfig) => {
|
||||||
const screenName = $.auth.data?.screenName;
|
const screenName = $.auth.data?.screenName;
|
||||||
if ($.auth.data?.accessToken) {
|
|
||||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (screenName) {
|
if (screenName) {
|
||||||
requestConfig.headers[
|
requestConfig.headers[
|
||||||
'User-Agent'
|
'User-Agent'
|
||||||
@@ -16,6 +12,13 @@ const addAuthHeader = ($, requestConfig) => {
|
|||||||
] = `web:automatisch:${appConfig.version}`;
|
] = `web:automatisch:${appConfig.version}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!requestConfig.additionalProperties?.skipAddingAuthHeader &&
|
||||||
|
$.auth.data?.accessToken
|
||||||
|
) {
|
||||||
|
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||||
|
}
|
||||||
|
|
||||||
return requestConfig;
|
return requestConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user