Skip to content

Commit

Permalink
fix(deezer): Fix deezer passport generation
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Sep 14, 2023
1 parent 6dc40e5 commit d5dfc33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/backend/server/deezerRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import passport from "passport";
export const setupDeezerRoutes = (app: ExpressWithAsync, logger: Logger, scrobbleSources: ScrobbleSources) => {

// initialize deezer strategies
const deezerSources = scrobbleSources.getByType('deezer') as DeezerSource[];
for(const d of deezerSources) {
passport.use(`deezer-${d.name}`, d.generatePassportStrategy());
}
// const deezerSources = scrobbleSources.getByType('deezer') as DeezerSource[];
// for(const d of deezerSources) {
// passport.use(`deezer-${d.name}`, d.generatePassportStrategy());
// }

// something about the deezer passport strategy makes express continue with the response even though it should wait for accesstoken callback and userprofile fetching
// so to get around this add an additional middleware that loops/sleeps until we should have fetched everything ¯\_(ツ)_/¯
Expand All @@ -34,6 +34,7 @@ export const setupDeezerRoutes = (app: ExpressWithAsync, logger: Logger, scrobbl
return res.send('Error with deezer credentials storage');
} else if(entity.config.data.accessToken !== undefined) {
// start polling
await entity.testAuth();
entity.poll()
return res.redirect('/');
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/backend/sources/DeezerSource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import request from 'superagent';
import passport from "passport";
import {
parseRetryAfterSecsFromObj,
readJson,
Expand Down Expand Up @@ -99,6 +100,7 @@ export default class DeezerSource extends AbstractSource {
this.logger.info(`Redirect URL that will be used on auth callback: '${this.redirectUri}'`);
}
this.initialized = true;
passport.use(`deezer-${this.name}`, this.generatePassportStrategy());
return this.initialized;
}

Expand Down
4 changes: 2 additions & 2 deletions src/backend/sources/ScrobbleSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export default class ScrobbleSources {
break;
case 'deezer':
const d = {
clientId: process.env.DEEZER_APP_ID,
clientSecret: process.env.DEEZER_SECRET_KEY,
clientId: process.env.DEEZER_CLIENT_ID,
clientSecret: process.env.DEEZER_CLIENT_SECRET,
redirectUri: process.env.DEEZER_REDIRECT_URI,
accessToken: process.env.DEEZER_ACCESS_TOKEN,
};
Expand Down

0 comments on commit d5dfc33

Please sign in to comment.