diff --git a/README.md b/README.md index 2932680..4f5b833 100644 --- a/README.md +++ b/README.md @@ -533,6 +533,21 @@ We can `deauthorize()` our user's from using the provider by calling the `deauth manager.deauthorize('twitter'); ``` +## Adding your own providers + +To add your own providers you can use the `addProvider()` method and fill in your provider details: + +```javascript +manager.addProvider({ + 'name_of_provider': { + auth_version: '2.0', + authorize_url: 'https://provider.dev/oauth', + access_token_url: 'https://provider.dev/oauth/token', + callback_url: ({app_name}) => `${app_name}://oauth`, + } +}); +``` + ## Contributing This is _open-source_ software and we can make it rock for everyone through contributions. diff --git a/react-native-oauth.js b/react-native-oauth.js index d97bc0d..4fd01c2 100644 --- a/react-native-oauth.js +++ b/react-native-oauth.js @@ -13,7 +13,9 @@ const OAuthManagerBridge = NativeModules.OAuthManager; let configured = false; const STORAGE_KEY = 'ReactNativeOAuth'; import promisify from './lib/promisify' -import authProviders from './lib/authProviders'; +import defaultProviders from './lib/authProviders'; + +let authProviders = defaultProviders; const identity = (props) => props; /** @@ -27,6 +29,10 @@ export default class OAuthManager { this._options = opts; } + addProvider(provider) { + Object.assign({}, authProviders, provider); + } + configure(providerConfigs) { return this.configureProviders(providerConfigs) } @@ -99,11 +105,11 @@ export default class OAuthManager { // Private /** * Configure a single provider - * - * + * + * * @param {string} name of the provider * @param {object} additional configuration - * + * **/ configureProvider(name, props) { invariant(OAuthManager.isSupported(name), `The provider ${name} is not supported yet`);