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

[FEAT]: method for generating installation url #541

Open
1 task done
rpmccarter opened this issue May 10, 2024 · 5 comments · May be fixed by #542
Open
1 task done

[FEAT]: method for generating installation url #541

rpmccarter opened this issue May 10, 2024 · 5 comments · May be fixed by #542
Labels
Type: Feature New feature or request

Comments

@rpmccarter
Copy link

Describe the need

We have multiple github apps - one for each environment of our service. We have an endpoint that simply returns the installation url for the github app. Right now, the endpoint looks something like this:

    const baseUrl = process.env.NODE_ENV === 'development'
      ? 'https://github.com/apps/mintlify-development/installations/new'
      : 'https://github.com/apps/mintlify/installations/new';

    const url = new URL(baseUrl);

    url.searchParams.append('state', stateString);

    return url.toString();

I wish we didn't have to hard-code the github app name or store it as an env var. I noticed that the @octokit/oauth-app package has a convenient method app.getWebFlowAuthorizationUrl(options) which generates the authorization URL. I looked for a similar function within the octokit app but wasn't able to find anything. Would be a neat little feature to have - happy to implement as well!

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rpmccarter rpmccarter added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels May 10, 2024
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@gr2m
Copy link
Contributor

gr2m commented May 10, 2024

what I usually do is to retrieve the app's HTML URL

const { data: appInfo } = await app.octokit.request("GET /app")
const installUrl = `${appInfo.html_url}/installations/new`

Does that work for you?

@rpmccarter
Copy link
Author

I could definitely use that instead, and the implementation of this method would probably look just like that, I just like the convenience of app.getWebFlowAuthorizationUrl(options) and wanted to check if it was something that could be added to the GitHub app - it's nice to be able to create the exact installation link without having to refer to the github api docs. If this is too trivial that's fine :)

@gr2m
Copy link
Contributor

gr2m commented May 10, 2024

The OAuth URL method is coming from this package: https://github.com/octokit/oauth-methods.js. We don't have a counterpart with methods for apps, but worth thinking about.

I suggest we leave this issue open, maybe others can share their perspective and we can pick it up again in future

@rpmccarter rpmccarter linked a pull request May 13, 2024 that will close this issue
4 tasks
@rpmccarter
Copy link
Author

rpmccarter commented May 13, 2024

Created PR #542 to address this, mostly for fun - let me know what you think! No worries if it doesn't get merged

@kfcampbell kfcampbell removed the Status: Triage This is being looked at and prioritized label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
Status: 🔥 Backlog
Development

Successfully merging a pull request may close this issue.

3 participants