cczinski
3 years agoNovice I
Ok, instead of making the token myself, I'm using jwt-simple
Ok, instead of making the token myself, I'm using jwt-simple to setup it up for me. Now, I'm just getting invalid issuer. Possibly adding something wrong somewhere.
```var privateKey = fs.readFileSync(__dirname + '/private.pem', 'utf8')
var currentTimestamp = Date.now()
var jwtHeader = {
'kid': ck.keyid
}
var jwtData = {
'aud': ck.clientid,
'sub': 'user',
'iss': ck.issuer,
'iat': currentTimestamp,
'exp': currentTimestamp + 3600
}
const token = jwt.encode(jwtData,{key: privateKey, passphrase: 'passwordhere'},'RS256',jwtHeader)
console.log("Token: " + token)
var url = 'https://xxxx/oauth2/1.0/token'
var config = {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
}
}
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
var body = {
'grant_type': 'urnparamsgrant-type:token-exchange',
'subject_token': token,
'subject_token_type': 'urnparamstoken-type:jwt'
}
http://axios.post|axios.post(url,qs.stringify(body),config).then((response) => {
console.log(response);
}, (error) => {
console.log("--Data sent--")
console.log(error.config)
console.log("---Error---")
console.log('Code: ', error)
});```