Reputation: 129
How can i use my github account in a chrome extension. I mean how can a get repo lists or something else in my own extension with my account? i find a lot of extension to github but i cant find the source how made it..
Upvotes: 0
Views: 460
Reputation: 2200
This is pretty simple, but I like to use a javascript wrapper rather then making the ajax calls myself. You will need to generate a oAuth token. Here is a working example.
If you are not familiar with oAuth it is basically a special password you create for your account which allows your extension to access your application's (GitHub) data. You can limit the access of this special password to only the information needed to prevent security issues.
https://github.com/settings/tokens/new
REMEBER to uncheck all checkboxes! This will only allow this password access to public information on your github account. Click Generate token
. Github.js requires Underscore.js
//get access to account
var github = new Github({
token: "e7e427e4a8cc0f424a77a0******************",
auth: "oauth"
});
//get user
var user = github.getUser();
//get repos
user.repos(function(err, repos) {
//loop through repos
for (i = 0; i < repos.length; i++) {
repo = repos[i];
//access repo here
}
});
Upvotes: 2
Reputation: 5511
They would have used the github API. Here is the documentation for the List Your Repositories API function: http://developer.github.com/v3/repos/#list-your-repositories
How you implement interaction with that is very much up to you.
Here are some resources to get you started
And seeming as you've tagged jQuery in your question, here is a jQuery plugin that is interacting with the github API which may help you understand how to use it. Good luck!
Upvotes: 1