Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot retrieve installationAccessToken #1399

Closed
Milredel opened this issue Jun 13, 2019 · 4 comments
Closed

Cannot retrieve installationAccessToken #1399

Milredel opened this issue Jun 13, 2019 · 4 comments

Comments

@Milredel
Copy link

Milredel commented Jun 13, 2019

I want my back-end to get all PR of all repo of my organisation. I created a github app, installed it and got my installation id and my private key (pem certificate).
But when I run this code :

const { App } = require("@octokit/app");
const { request } = require("@octokit/request");
const APP_ID = XXXX;
const PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----\nXXXXXXXXX";            
const installation_id = YYYY;
const app = new App({ id: APP_ID, privateKey: PRIVATE_KEY });
const installationAccessToken = await app.getInstallationAccessToken({
    installation_id
});

All I can get is this :

{ HttpError: 'Expiration time' claim ('exp') is too far in the future
    at response.text.then.message (/Users/Morgan/dev/ezdeploy/node_modules/@octokit/request/dist-node/index.js:85:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Am I missing something ?
Thanks for the help

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.64. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@Milredel
Copy link
Author

OK, I had time to further investigate the issue and it seems that expirationTime for the jwt is too high.
in @octokit/app/dist_node/index.js the payload is built like that :
const payload = { iat: now, exp: now + 60 * 10, iss: id };
10 minutes seems too much in the future. I just put 8 and I managed to retrieve my installationAccessToken...

@gr2m
Copy link
Contributor

gr2m commented Jun 13, 2019

Hi @Milredel, we just fixed that very problem yesterday in octokit/app.js#36, make sure you update @octokit/app to the latest version (3.0.1)

@stale
Copy link

stale bot commented Jul 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 11, 2019
@gr2m gr2m closed this as completed Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants