[英]How to get curl “Authorization token(OAuth token)” programmatically (using JS/PHP ) for github user?
我現在正在與Github合作。我該如何為github登錄用戶獲取“ OAuth令牌”。現在我有了client_id,Client Secret,access_toke之類的數據(這些數據僅在登錄github后才獲得)。通過以上數據獲取OAuth令牌。
我通過以下命令行獲得了oauth toke:
[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)。
誰能幫忙...謝謝....
請編輯您的問題以刪除您的“ client_id”,並返回令牌。 另外,請轉到您的應用設置並獲取新的“ client_secret”。 所有這些信息都不應公開給任何人 。
現在,如果您打算使用JavaScript或PHP中的cURL,那么您將度過非常糟糕的時光。 我將研究如何在每個請求中發出HTTP / 1.1請求,並查看一些為您包裝API的PHP或JavaScript現有庫 。 有了這些東西(從來沒有在所有情況下使用過它們),您應該應該收到類似於哈希或其他數據結構的東西,以便能夠檢索該信息。 如果您閱讀了他們的文檔,那么您會比從來沒有使用任何這些庫的人告訴您該怎么做要好得多。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.