简体   繁体   中英

Get the api oath access token from reddit api

I got the code successfully from the reddit oauth api but I am getting invalid grant(Before I was getting 401 unauthorized on sending data as json) error when trying to get the access token after that. I am using postman for sending the post request to https://www.reddit.com/api/v1/access_token Here is My header and form data which I am using in postman. I am sending my client id and secret in authorization tab(tried in sending header) from postman and using x-www-form-urlencoded to send grant type, code and redirect uri(tried sending them as a form data and json as well). In headers my content type is x-www-form-urlencoded. Please help in getting the token if someone have used 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 分钟后过期

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