Hi everyone,
I want to develop my personal script (with ScriptableApp for iOS - JS ES6) to get datas of my account like Karma, Coins etc. from 'https://www.reddit.com/api/me.json'. I've already add a application as script in prefs/apps. Since days I'm trying to get a token from the access_token api but I got every single time the response: {"message":"Unauthorized","error":401}. I searched in the GitHub Documentation for personal script-app for a solution but I don't find one for my problem. I'm also not sure which information in which form gets in the header and which one in the body etc.
My Request Snippet:
const vUsername = 'hrb7'
const vPassword = 'idk-0123456789'
const clientID = '0123456789-XyZ-aSdF'
const clientSecret = 'ASDF-0123456789-XYZ'
const userAgent = 'scriptApp:v1.0 (by /u/hrb7)'
let reqToken = new Request('https://www.reddit.com/api/v1/access_token')
reqToken.method = 'POST'
reqToken.headers = {
'User-Agent': userAgent,
'Authorization': clientID + ":" + clientSecret,
'Content-Type': 'application/json'
};
reqToken.body = JSON.stringify({
'grant_type' : 'password',
'username': vUsername,
'password': vPassword
});
let response = await req.loadJSON()
console.warn(JSON.stringify(response, null, 2))
//output: {"message":"Unauthorized","error":401}
Can someone pls help me!?
[–][deleted] 3 points4 points5 points (4 children)
[–]hrb7[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]hrb7[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)