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

Property 'token' does not exist on type 'Authentication' #282

Closed
jwenz723 opened this issue May 1, 2021 · 4 comments · Fixed by #283
Closed

Property 'token' does not exist on type 'Authentication' #282

jwenz723 opened this issue May 1, 2021 · 4 comments · Fixed by #283
Assignees
Labels
Type: Bug Something isn't working as documented, or is being fixed typescript Relevant to TypeScript users only
Projects

Comments

@jwenz723
Copy link

jwenz723 commented May 1, 2021

I am going to start out by saying I am a total typescript/javascript newb.

I am trying to create a github action using this @octokit/auth-app library. I am trying to authenticate to github using an installation ID. For some reason the typing isn't setup properly to allow access of the token property of the object that is returned after calling createAppAuth. I was able to resolve my issue by adding : any to cast to the generic any type so that properties can be referenced generically. But this doesn't seem like an ideal solution.

Here is my code that does not succeed:

const auth = createAppAuth(createAppAuthOptions);
const installation = await auth({
    installationId: installationId,
    type: "installation",
});
return installation.token;

This code results in the following error when compiling:

TS2339: Property 'token' does not exist on type 'Authentication'.
  Property 'token' does not exist on type 'AppAuthentication'.

Here is my successful code with the any type workaround:

const auth = createAppAuth(createAppAuthOptions);
const installation:any = await auth({
    installationId: installationId,
    type: "installation",
});
return installation.token;

Any suggestions on what I should be doing differently, or is this a bug?

@ghost ghost added this to Inbox in JS May 1, 2021
@wolfy1339 wolfy1339 added the typescript Relevant to TypeScript users only label May 1, 2021
@gr2m gr2m added the Type: Bug Something isn't working as documented, or is being fixed label May 1, 2021
@ghost ghost moved this from Inbox to Bugs in JS May 1, 2021
@gr2m
Copy link
Contributor

gr2m commented May 1, 2021

Something is indeed not working correctly, I was able to reproduce the problem with a TypeScript playground

I'm looking into it

@gr2m gr2m self-assigned this May 1, 2021
@ghost ghost moved this from Bugs to In progress in JS May 1, 2021
@gr2m
Copy link
Contributor

gr2m commented May 1, 2021

I am trying to create a github action using this @octokit/auth-app library

By the way I just did a live coding show where I created a GitHub action that authenticates as an app, it's using the App SDK octokit, maybe give that a try?

Here is more info on the show and links to the video: gr2m/helpdesk#1

@gr2m
Copy link
Contributor

gr2m commented May 1, 2021

I started a PR with a failing test at #283. I'll look into fixing this the coming week. I think I'll have to rewrite the types, similar to how they work in @octokit/auth-oauth-app. If you feel like hacking on it this weekend, please go ahead, you can start out with the failing test I created and try to fix it

@gr2m gr2m closed this as completed in #283 May 31, 2021
JS automation moved this from In progress to Done May 31, 2021
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 3.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented, or is being fixed typescript Relevant to TypeScript users only
Projects
No open projects
JS
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants