I got it to work by adding

"Content-Type" => "application/x-www-form-urlencoded"


To the header. See 
https://github.com/JuliaWeb/Requests.jl/issues/52#issuecomment-117821209

On Wednesday, July 1, 2015 at 1:45:54 PM UTC+2, Patrick Kofod Mogensen 
wrote:
>
>
>
> I'm trying to get a token to access Reddits API. I can get one perfectly 
> fine with
>
> curl -X POST -d 'grant_type=password&username=[MYNAME]&password=[MYPASS]' 
> --user 'CLIENTID:CLIENTSECRET' https://www.reddit.com/api/v1/access_token
>
> This gives me what I need. I kind of want to retrieve it directly from 
> julia (maybe to be used in a Reddit.jl-package), but I can't get it to 
> work. I would have guessed that the following post-request was the same, 
> but it seems not to be the case.
>
> enc = bytestring(encode(Base64, "CLIENTID:CLIENTSECRET"))
> post(URI("https://www.reddit.com/api/v1/access_token";), 
> "grant_type=password&username=[MYNAME]&password=[MYPASS]"; headers = 
> Dict("Authorization" => "Basic $enc", "User-Agent" => UserAgent))
> % UserAgent is a string here
>
> Do you have any idea why these POST requests are not the same ? They can't 
> be, as the Julia post call gives me
>
> "{\"error\": \"unsupported_grant_type\"}"
>
> Is there maybe a way for me to see the POST request produced by post()?
>
> Thanks for the help in advance.
> Patrick
>

Reply via email to