Rio
Rio

Reputation: 672

Generate personal access token in github using api

Is there any way I can login to my github account via my username and password and generate personal access token using api ?

Upvotes: 11

Views: 10812

Answers (2)

Victor Bouhnik
Victor Bouhnik

Reputation: 121

UPDATE: per this blog post, they've deprecated the OAuth Authorizations API, that support generating personal access tokens.

so now, you'll have to generate it using the web settings page instead.

Original answer:

Calls to OAuth Authorizations API

If you're making OAuth Authorization API calls to manage your OAuth app's authorizations or to create personal access or OAuth tokens like:

curl -u my_username:my_password -X POST "https://api.github.com/authorizations" -d '{"scopes":["public_repo"], "note":"my token", "client_id":"my_client_id", "client_secret":"my_client_secret"}'

Then you must switch to the web application flow to generate access tokens.

Upvotes: 11

Rio
Rio

Reputation: 672

I found the solution. With reference to GitHub documentation https://developer.github.com/v3/guides/getting-started/#authentication I got it passed and able to make a python script that can serve my purpose.

Here is what should work (Postman example):

POST https://mycloud.example.com/api/v3/authorizations
{
  "note" : "example-1",
  "scopes" : [
    "repo"
  ]
}

Upvotes: -1

Related Questions