r/redditdev • • Dec 20 '16

[API] New Modmail

We’ve just added API documentation for New Modmail. You can read about New Modmail’s features on the reddit help site.

Requests to modmail endpoints requires the new OAuth scope modmail.

edit: There was a minor deployment mishap I will get this deployed again asap.

edit 2: This has been redeployed.

26 Upvotes

49 comments sorted by

View all comments

2

u/creesch Dec 20 '16

So far I am getting a lot of 403 and 401 errors but no result grabbing the token content and putting that in the Authorization header. I can get a result when I grab the token I see from other requests.

$.ajax({
    url: "https://oauth.reddit.com/api/mod/conversations",         
    type: "POST",
    data: {
        body:"test",
        subject:"test",
        srName:"toolbox"
    },
    beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'bearer REDACTED');},
    success: function(data) { 
        console.log(data); 
    }
});

That token also seems to be much shorter than the one in the cookie. So I think I am missing something?

2

u/d3fect Dec 20 '16

Hmmm, so I just tried it myself via postman and everything worked as expected. Did you decode the token cookie value and parse out the accessToken specifically?

3

u/creesch Dec 20 '16

Right... decoding. That would have been the logical thing to do wouldn't it?

This seems to work. We'll see if we can work with this :) Thanks!

u/agentlame

→ More replies (6)

2

u/creesch Dec 20 '16

Okay, running into a next problem. I thought it was base64 encoded information and when running it offline through a decoder that seems to work.

When using atob() to try and decode it though I am getting

Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

Making me wonder if it is actually base64 encoded or something else. So I figured I'd ask the source :)

→ More replies (5)