You are viewing a single comment's thread from:
RE: Tutorial: OAuth2 Access Tokens and Refresh Tokens with Steemconnect
This is THE most helpful tutorial to exist. Thank you!
I do have one question though:
After requesting the refresh token with the code, my url only redirects with the same code. This is difficult to explain, but I am able to return all data except the refresh token. (CAN get username and access token)
This is my code:
router.get('/', function(req, res, next) {
let code = req.query.code;
if (code) {
return rp({
method: "POST",
uri: "https://steemconnect.com/api/oauth2/token",
body: {
response_type: "refresh",
code: code,
client_id: "appname",
client_secret: process.env.SC_CLIENT_SECRET,
scope: "vote"
},
json: true
}).then((results) => {
//let qs = "access_token=" + results.access_token + "&refresh_token=" + results.refresh_token + "&username=" + results.username;
res.render('customize', { title: "appname", username: results.refresh_token, refresh_token: results.refresh_token });
// results.refresh_token returns undefined?
});
}
});
Any help would be much appreciated. Thanks!
You used
https://v2.steemconnect.com/oauth2/authorize?client_id=appname&response_type=code&redirect_uri=https%3A%2F%2Fappname.herokuapp.com%2F&scope=vote
? It returned acode
in the query string, and that's what you're using forcode
, right?The
POST
to/api/oauth2/token
JSON response was valid? Do you have that? I just want to verify the structure.I did use the url. Callback url went to:
http://localhost:3000/customize?code=longcodeherebutpopulatedwithactualcode
I am having difficulty debugging in express, and my console.log statements aren't working, so I have no way to tell if the response was valid. Thanks for the quick response!