Skip to content

Commit 9620531

Browse files
authored
Merge pull request fullstackreact#70 from mistenkt/master
Added method for adding own providers via OAuthManager
2 parents 1ee273b + bd18bcd commit 9620531

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,21 @@ We can `deauthorize()` our user's from using the provider by calling the `deauth
533533
manager.deauthorize('twitter');
534534
```
535535

536+
## Adding your own providers
537+
538+
To add your own providers you can use the `addProvider()` method and fill in your provider details:
539+
540+
```javascript
541+
manager.addProvider({
542+
'name_of_provider': {
543+
auth_version: '2.0',
544+
authorize_url: 'https://provider.dev/oauth',
545+
access_token_url: 'https://provider.dev/oauth/token',
546+
callback_url: ({app_name}) => `${app_name}://oauth`,
547+
}
548+
});
549+
```
550+
536551
## Contributing
537552

538553
This is _open-source_ software and we can make it rock for everyone through contributions.

react-native-oauth.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const OAuthManagerBridge = NativeModules.OAuthManager;
1313
let configured = false;
1414
const STORAGE_KEY = 'ReactNativeOAuth';
1515
import promisify from './lib/promisify'
16-
import authProviders from './lib/authProviders';
16+
import defaultProviders from './lib/authProviders';
17+
18+
let authProviders = defaultProviders;
1719

1820
const identity = (props) => props;
1921
/**
@@ -27,6 +29,10 @@ export default class OAuthManager {
2729
this._options = opts;
2830
}
2931

32+
addProvider(provider) {
33+
Object.assign({}, authProviders, provider);
34+
}
35+
3036
configure(providerConfigs) {
3137
return this.configureProviders(providerConfigs)
3238
}
@@ -99,11 +105,11 @@ export default class OAuthManager {
99105
// Private
100106
/**
101107
* Configure a single provider
102-
*
103-
*
108+
*
109+
*
104110
* @param {string} name of the provider
105111
* @param {object} additional configuration
106-
*
112+
*
107113
**/
108114
configureProvider(name, props) {
109115
invariant(OAuthManager.isSupported(name), `The provider ${name} is not supported yet`);

0 commit comments

Comments
 (0)