Programmatically:
You can write down program to complete the ask but it does not worth the effort until you are in really need it. You can use any programming language to do this magic whether you are using Python (PyGithub), Ruby (Oktokit) or Go (go-github), it's pretty straight-forward if you get hold on the libraries.
Via Script/Curl:
But as I said earlier, It is too much to write code if you have to do only this. It can be done pretty easily with simple curl. Github provides API to fetch the authenticated user details which we can tweak for Github enterprise as well.
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user
Let's see the complete script -
Demo:
No comments:
Post a Comment