This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Configuring Reddit Rest Operations
To use the Reddit connector, add the <reddit.init>
element in your configuration before carrying out any other Reddit operations.
There are operations with authentication and without authentication.For Authentication, OAuth2 support allows you to use reddit to authenticate on non-reddit websites and applications.
API requests are made via HTTPS using your account's unique Reddit URL. Each request must be authenticated with a user's API authentication token using HTTP basic authentication. For more information, see https://github.com/reddit/reddit/wiki/OAuth2.
Reddit connector uses Authorization Code Flow.
Note
When you try to get the code for the created secret app please use scope as following
"scope=identity,edit,flair,history,mysubreddits,privatemessages,read,report,save,submit,subscribe,vote,wikiedit,wikiread"
because, then only you can get that created app as authorized applications with that defined scope.
You can follow the following steps to import your Reddit certificate into wso2esb client’s keystore as follows:
Go to https://www.reddit.com/ in your browser, and then click the HTTPS trust icon on the address bar (e.g., the padlock next to the URL in Chrome).
View the certificate details (the steps vary by browser) and then export the trust certificate to the file system.
Use the ESB Management Console or the following command to import that certificate into the ESB client keystore.
keytool -importcert -file CERT_FILE_NAME -keystore <ESB_HOME>/repository/resources/security/client-truststore.jks -alias "CERT_NAME"
NOTE : CERT_FILE_NAME - Replace CERT_FILE_NAME with the file name that was extracted from reddit with the extension. (e.g. reddit.crt)
CERT_NAME - Replace CERT_NAME with an arbitrary name for the certificate. (e.g. reddit)
ESB should be configured as below.
Ensure that the following Axis2 configurations are added and enabled in the
<ESB_HOME>\repository\conf\axis2\axis2.xml
file.Required message formatters
messageFormatters<messageFormatter contentType="text/html" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/> <messageFormatter contentType="text/plain" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
Required message builders
messageBuilders<messageBuilder contentType="text/html" class="org.wso2.carbon.relay.BinaryRelayBuilder"/> <messageBuilder contentType="text/plain" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
Restart the server and deploy the Reddit configuration.
init<reddit.init> <apiUrlOauth>https://oauth.reddit.com</apiUrlOauth> <apiUrl>https://www.reddit.com</apiUrl> <apiVersion>v1</apiVersion> <accessToken>42591910-APa9HJeLE1jV2EjpIxigdTi79mw</accessToken> </reddit.init>
Properties
apiUrlOauth : URL of the Reddit API for oauth scope methods.
apiUrl : URL of the Reddit API.
apiVersion
: Version of the API.accessToken : Use Refresh token to get access token.
Now you have connected to Reddit, use the information in the following resources to perform the operations with the connector.