Home > Software engineering >  Is there a way to accept github invitation as collaborator automatically? Preferably with octokit?
Is there a way to accept github invitation as collaborator automatically? Preferably with octokit?

Time:03-17

I've been using octokit to fetch github repos and their commits, but I realized that if the repo is private then the person must invite me, and I have to accept that manually every time. I found this as a solution but to be honest I am not sure how I could use it.

This is the method I fetch github repos:

<script type="module">
        import { Octokit } from "https://cdn.pika.dev/@octokit/core";
        
        const octokit = new Octokit({ auth: "*authkey*" });
        octokit.request('GET /repos/:owner/:repo/commits', {
        owner: "*owner*",
        repo: "*repo*"
        }).then(response => console.log(response.data))
    </script>
    

Thank you for your help in advance!

CodePudding user response:

I've never worked with GitHub invitations via API but apparently Octokit offers the option to create an invite, list all existing invites for a user or a repository and accept or decline an invite:

I guess you can play with this and get your goal, right?

Also, if you are using GitHub API for a certain group of repositories, I recommend you take a look into https://github.com/octoherd. It offers an easy way to create scripts and re-use existing utilities for interacting with GitHub's API with Octokit.

Let us know if you still have problems with this.

  • Related