using IDNOT_REDIRECT_URL instead of APP_HOST

This commit is contained in:
Vins 2023-12-01 11:56:50 +01:00
parent a3e88cdbd2
commit 7c07b5674d
2 changed files with 6 additions and 3 deletions

View File

@ -22,7 +22,7 @@ export default class UserController extends ApiController {
protected async getUserInfosFromIdnot(req: Request, response: Response) { protected async getUserInfosFromIdnot(req: Request, response: Response) {
try { try {
const code = req.params["code"]; const code = req.params["code"];
if (!code) throw new Error("code is required"); if (!code) throw new Error("code is required");
const idNotToken = await this.idNotService.getIdNotToken(code); const idNotToken = await this.idNotService.getIdNotToken(code);
if(!idNotToken) { if(!idNotToken) {

View File

@ -117,11 +117,14 @@ export default class IdNotService extends BaseService {
const query = new URLSearchParams({ const query = new URLSearchParams({
client_id: this.variables.IDNOT_CLIENT_ID, client_id: this.variables.IDNOT_CLIENT_ID,
client_secret: this.variables.IDNOT_CLIENT_SECRET, client_secret: this.variables.IDNOT_CLIENT_SECRET,
redirect_uri: `${this.variables.APP_HOST}/authorized-client`, redirect_uri: this.variables.IDNOT_REDIRECT_URL,
code: code, code: code,
grant_type: "authorization_code", grant_type: "authorization_code",
}); });
const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" }); const token = await fetch(this.variables.IDNOT_BASE_URL + this.variables.IDNOT_CONNEXION_URL + "?" + query, { method: "POST" });
if(token.status !== 200) console.error(await token.text());
const decodedToken = (await token.json()) as IIdNotToken; const decodedToken = (await token.json()) as IIdNotToken;
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload; const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;