Logged token

This commit is contained in:
Vins 2023-09-21 11:19:31 +02:00
parent aa6a705bc7
commit 92111211d4

View File

@ -107,15 +107,22 @@ export default class IdNotService extends BaseService {
} }
public async getIdNotToken(code: string) { public async getIdNotToken(code: string) {
const redirect_uri: string = `${this.variables.APP_HOST}/authorized-client`;
console.log(redirect_uri);
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.APP_HOST + "/authorized-client",
code: code, code: code,
grant_type: "authorization_code", grant_type: "authorization_code",
}); });
console.log(query);
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" });
const decodedToken = (await token.json()) as IIdNotToken; const decodedToken = (await token.json()) as IIdNotToken;
console.log(decodedToken);
const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload; const decodedIdToken = jwt.decode(decodedToken.id_token) as IdNotJwtPayload;
return decodedIdToken; return decodedIdToken;
} }