Search code examples
androidkotlinhttp-status-code-403reddit

403 Error while trying to retrieve Reddit User's saved posts using JRAW


I'm currently trying to get a users saved posts using the JRAW reddit api wrapper using this code:

val helper = App.get().accountHelper
val paginator = helper.reddit.me()
                    .history("saved")
                    .build()

val saved = paginator.next()

Context for App class

Which always results in a 403 - Forbidden. I log in and get the oauth token by using JRAW-Android new user example then switch to the user accountHelper.switchToUser(userName) which shows the account is authenticated..

Any ideas why i'm not able to authenticate?


Solution

  • Didn't realize Reddit had scopes. I had to add the history scope to the strings array when requesting getAuthorizationUrl

    String[] scopes = new String[]{ "read", "identity", "account", "save", "history"};
    String authUrl = helper.getAuthorizationUrl(requestRefreshToken, useMobileSite, scopes);