Skip to content

Commit b32fd54

Browse files
author
Kadi Kraman
authored
Merge pull request #435 from FormidableLabs/chore/github-auth-example
Add a config example for GitHub
2 parents 968daa3 + bcf2ce0 commit b32fd54

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ These providers implement the OAuth2 spec, but are not OpenID providers, which m
4141
* [Dropbox](https://www.dropbox.com/developers/reference/oauth-guide) ([Example configuration](./docs/config-examples/dropbox.md))
4242
* [Reddit](https://github.com/reddit-archive/reddit/wiki/oauth2) ([Example configuration](./docs/config-examples/reddit.md))
4343
* [Coinbase](https://developers.coinbase.com/docs/wallet/coinbase-connect/integrating) ([Example configuration](./docs/config-examples/coinbase.md))
44+
* [GitHub](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/) ([Example configuration](./docs/config-examples/github.md))
4445

4546
## Why you may want to use this library
4647

docs/config-examples/github.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# GitHub
2+
3+
** This is Android Only **
4+
5+
Read more about iOS restrictions [here](https://github.com/FormidableLabs/react-native-app-auth/issues/194).
6+
7+
Go to [OAuth Apps](https://github.com/settings/developers) to create your app.
8+
9+
For the Authorization callback URL, choose something like `com.myapp://oauthredirect` and ensure you use `com.myapp` in your `appAuthRedirectScheme` in `android/app/build.gradle`.
10+
11+
```js
12+
const config = {
13+
redirectUrl: 'com.my.auth.app://oauthredirect',
14+
clientId: '<client-id>',
15+
clientSecret: '<client-seret',
16+
scopes: ['identity'],
17+
serviceConfiguration: {
18+
authorizationEndpoint: 'https://github.com/login/oauth/authorize',
19+
tokenEndpoint: 'https://github.com/login/oauth/access_token',
20+
revocationEndpoint:
21+
'https://github.com/settings/connections/applications/<client-id>'
22+
}
23+
};
24+
25+
// Log in to get an authentication token
26+
const authState = await authorize(config);
27+
```

0 commit comments

Comments
 (0)