简体   繁体   中英

How to get curl “Authorization token(OAuth token)” programmatically (using JS/PHP ) for github user?

I am working with Github now.How can i suppose to get the "OAuth token" for github login user.Now i have the Data like client_id,Client Secret,access_toke(these all data getting after login to github only).how can i get the OAuth token through the above data.

I got oauth toke through command line like:

[root@localhost Dinesh]# curl -u 'DineshGK' -d '{"scopes":["repo"],"note":"Help example"}' https://api.github.com/authorizationsEnter host password for user 'DineshGK':
[root@localhost Dinesh]# curl https://api.github.com/authorizations --user "DineshGK" --data '{"scopes":["user"], "client_id":"...", "client_secret":"..."}'
Enter host password for user 'DineshGK':
{
  "id": 2300973,
  "url": "https://api.github.com/authorizations/2300973",
  "app": {
    "name": "SenchaPlayground",
    "url": "http://192.168.1.56/OldPlayground/"
  },
  ****"token": "..."**,**
  "note": null,
  "note_url": null,
  "created_at": "2013-04-16T07:34:21Z",
  "updated_at": "2013-04-16T07:34:21Z",
  "scopes": [
    "user"
  ]
}

I want that Highlighted token pragmatically(using JS/PHP)..

Can any one help... Thanks in advance ....

Please edit your question to remove your "client_id", and the token returned. Also, please go to your app settings and get a new "client_secret". None of that information should ever be made public to ANYONE .

Now, if your intent is to use cURL from JavaScript or PHP, you're going to have a very bad time. I would look into the how to make HTTP/1.1 requests in each and check out some of the existing libraries for either PHP or JavaScript that wrap the API for you. With those in hand (having never used any of them in all candor) you should probably receive something akin to a Hash or some other data structure to be able to retrieve that information. If you read their documentation you'll do a lot better than someone telling you what to do who has never used any of those libraries.

You can't completely automate this process, the user must be involved to manually grant access to your application. That said, Temboo simplifies the OAuth process for GitHub by breaking it into two steps:

  1. Generate an authorization URL that you can display to your user. This allows the user to authorize you to use their GitHub account. The first step also generates the callback URL you'll need for the second step of the process.

  2. Retrieve an access token once the user has granted access to your application.

Full details on how Temboo simplifies GitHub OAuth (using PHP) can be found here .

(Full disclosure: I work at Temboo)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM