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