![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
simple-oauth2-reddit
Advanced tools
This library is a wrapper around Simple OAuth2 Library
Specially made for Authorization Code Flow with Reddit.
Latest Node 8 LTS or newer versions.
npm install --save simple-oauth2 simple-oauth2-reddit
or
yarn add simple-oauth2 simple-oauth2-reddit
const simpleOAuth2Reddit = require('simple-oauth2-reddit');
const reddit = simpleOAuth2Reddit.create(options);
reddit
object exposes 3 keys:
access_token
Required options
Option | Description |
---|---|
clientId | Your App Id. |
clientSecret | Your App Secret Id. |
callbackURL | Callback configured when you created the app. |
state | Your CSRF anti-forgery token. More at: https://auth0.com/docs/protocols/oauth2/oauth-state |
Other options
Option | Default | Description |
---|---|---|
scope | ['identity'] | https://github.com/reddit-archive/reddit/wiki/OAuth2#authorization |
returnError | false | When is false (default), will call the next middleware with the error object. When is true, will set req.tokenError to the error, and call the next middleware as if there were no error. |
authorizeHost | 'https://www.reddit.com' | |
authorizePath | '/api/v1/authorize' | |
tokenHost | 'https://www.reddit.com' | |
tokenPath | '/api/v1/access_token' | |
authorizeOptions | {} | Pass extra parameters when requesting authorization. |
tokenOptions | {} | Pass extra parameters when requesting access_token. |
const oauth2 = require('simple-oauth2').create({
client: {
id: process.env.REDDIT_APP_ID,
secret: process.env.REDDIT_APP_SECRET
},
auth: {
authorizeHost: 'https://www.reddit.com'
authorizePath: '/api/v1/authorize',
tokenHost: 'https://www.reddit.com',
tokenPath: '/api/v1/access_token'
}
});
router.get('/auth/reddit', (req, res) => {
const authorizationUri = oauth2.authorizationCode.authorizeURL({
redirect_uri: 'http://localhost:3000/auth/reddit/callback',
scope: ['identity'],
state: 'random-unique-string'
});
res.redirect(authorizationUri);
});
router.get('/auth/reddit/callback', async(req, res) => {
const code = req.query.code;
const options = {
code,
state: 'same-random-unique-string',
redirect_uri: 'http://localhost:3000/auth/reddit/callback'
};
try {
// The resulting token.
const result = await oauth2.authorizationCode.getToken(options);
// Exchange for the access token.
const token = oauth2.accessToken.create(result);
return res.status(200).json(token);
} catch (error) {
console.error('Access Token Error', error.message);
return res.status(500).json('Authentication failed');
}
});
const simpleOAuth2Reddit = require('simple-oauth2-reddit');
const reddit = simpleOAuth2Reddit.create({
clientId: process.env.REDDIT_APP_ID,
clientSecret: process.env.REDDIT_APP_SECRET,
callbackURL: 'http://localhost:3000/auth/reddit/callback',
state: 'random-unique-string'
});
// Ask the user to authorize.
router.get('/auth/reddit', reddit.authorize);
// Exchange the token for the access token.
router.get('/auth/reddit/callback', reddit.accessToken, (req, res) => {
return res.status(200).json(req.token);
});
FAQs
A simple Node.js client library for Reddit OAuth2.
The npm package simple-oauth2-reddit receives a total of 0 weekly downloads. As such, simple-oauth2-reddit popularity was classified as not popular.
We found that simple-oauth2-reddit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.