我现在正在与Github合作。我怎么能为github登录用户获取“OAuth令牌”。现在我有像client_id,Client Secret,access_toke这样的数据(这些数据仅在登录github后获得)。如何通过上述数据获取OAuth令牌。
我通过命令行得到了oauth,如:
[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"
]
}
我实际想要那个突出显示的标记(使用JS / PHP)..
任何人都可以帮忙...... 提前谢谢....
答案 0 :(得分:0)
请编辑您的问题以删除“client_id”,并返回令牌。此外,请转到您的应用程序设置并获得一个新的“client_secret”。 任何信息都不应公开给任何人。
现在,如果你的意图是使用JavaScript或PHP的cURL,那么你将会遇到非常糟糕的时间。我将研究如何在每个请求中生成HTTP / 1.1请求,并查看一些现有的libraries,用于为您包装API的PHP或JavaScript。有了手头的人(从来没有使用任何一个),你应该收到类似于哈希或其他一些数据结构的东西,以便能够检索到这些信息。如果你阅读他们的文档,你会比告诉你从未使用过任何这些库的人做的更好。
答案 1 :(得分:0)