Skip to content

Commit 4f53fe4

Browse files
authored
Add docs for authenticating on reddit (#266)
1 parent d63968d commit 4f53fe4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ These providers implement the OAuth2 spec, but are not OpenID providers, which m
3838
* [Uber](https://developer.uber.com/docs/deliveries/guides/three-legged-oauth.md) ([Example configuration](./docs/config-examples/uber))
3939
* [Fitbit](https://dev.fitbit.com/build/reference/web-api/oauth2/) ([Example configuration](./docs/config-examples/fitbit.md))
4040
* [Dropbox](https://www.dropbox.com/developers/reference/oauth-guide) ([Example configuration](./docs/config-examples/dropbox.md))
41+
* [Reddit](https://github.com/reddit-archive/reddit/wiki/oauth2) ([Example configuration](./docs/config-examples/reddit.md))
4142

4243
## Why you may want to use this library
4344

docs/config-examples/reddit.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Reddit
2+
3+
** This is Android Only **
4+
5+
Log in and go to [apps](https://www.reddit.com/prefs/apps) to create your app.
6+
7+
Choose "installed app" and give it a name, description and about url of your choosing.
8+
9+
For the redirect uri, choose something like `com.myapp//oauth2redirect/reddit` and make sure that you use `com.myapp` in your `appAuthRedirectScheme` in `android/app/build.gradle`.
10+
11+
Reddit requires for you to add a [basic auth header](https://github.com/reddit-archive/reddit/wiki/oauth2#retrieving-the-access-token) to the token request.
12+
13+
```js
14+
const config = {
15+
redirectUrl: 'com.myapp://oauth2redirect/reddit',
16+
scopes: ['identity'], // include the scopes you need
17+
serviceConfiguration: {
18+
authorizationEndpoint: 'https://www.reddit.com/api/v1/authorize.compact',
19+
tokenEndpoint: 'https://www.reddit.com/api/v1/access_token',
20+
},
21+
customHeaders: {
22+
token: {
23+
Authorization: 'Basic <base64encoded clientID:>',
24+
},
25+
},
26+
};
27+
28+
// Log in to get an authentication token
29+
const authState = await authorize(config);
30+
```

0 commit comments

Comments
 (0)