簡體   English   中英

從 reddit api 獲取 api 誓言訪問令牌

[英]Get the api oath access token from reddit api

我從 reddit oauth api 成功獲得了代碼,但是之后嘗試獲取訪問令牌時,我得到了無效的授權(在我以 json 格式發送數據時獲得 401 未授權之前)錯誤。 我正在使用郵遞員將發布請求發送到https://www.reddit.com/api/v1/access_token這是我在郵遞員中使用的標題和表單數據。 我正在從郵遞員的授權選項卡中發送我的客戶端 ID 和密碼(嘗試發送標頭),並使用 x-www-form-urlencoded 發送授權類型、代碼和重定向 uri(嘗試將它們作為表單數據和 json 發送) . 在標題中,我的內容類型是 x-www-form-urlencoded。 如果有人使用過 reddit api,請幫助獲取令牌。

//Headers
Content-Type:application/x-www-form-urlencoded
//authorization
Authorization:Basic Base.Encode64(clientid:secret)
//client id and secret are those which I got by creating the app in reddit
//x-www-form-urlencoded.
{
    "grant_type":"authorization_code",
    "code":"authcode which I got from the get request before",
    "redirect_uri":"http://localhost:3000"
}
//I tried sending these through query string as well

如果我沒記錯的話,你的令牌會在 3600 分鍾后過期

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM