From 98338b2866cf1bd2faed8a034da74fdf90b8f0e4 Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 31 Oct 2017 10:25:30 +0000 Subject: [PATCH 1/3] Open URL callback --- src/oauth/auth.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/oauth/auth.js b/src/oauth/auth.js index 403d6dd..ba07c30 100644 --- a/src/oauth/auth.js +++ b/src/oauth/auth.js @@ -1,4 +1,4 @@ -import {Linking} from 'react-native'; +import {Linking,Modal} from 'react-native'; import URLSearchParams from 'url-search-params'; @@ -63,6 +63,7 @@ export default async function auth( tokens, callbackUrl, {accessType, forSignIn = false, forceLogin = false, screenName = ''} = {}, + openUrl ) { const usePin = typeof callbackUrl.then === 'function'; const {requestToken, requestTokenSecret} = await getRequestToken( @@ -70,9 +71,10 @@ export default async function auth( usePin ? 'oob' : callbackUrl, accessType, ); - Linking.openURL(`https://api.twitter.com/oauth/${forSignIn ? 'authenticate' : 'authorize'}?${ - query({oauth_token: requestToken, force_login: forceLogin, screen_name: screenName}) - }`); + const url = `https://api.twitter.com/oauth/${forSignIn ? 'authenticate' : 'authorize'}?${ + query({oauth_token: requestToken, force_login: forceLogin, screen_name: screenName}) + }`; + openUrl ? openUrl(url):Linking.openURL(url); return getAccessToken( {...tokens, requestToken, requestTokenSecret}, await ( From 6daa18ab93e7e91017f02a974b837b51a900b4a3 Mon Sep 17 00:00:00 2001 From: kyle Date: Tue, 31 Oct 2017 10:48:32 +0000 Subject: [PATCH 2/3] Updated readme for Open URL callback --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1751427..6b19af8 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Get the client's authentication tokens via [3-legged authorization](https://dev. * `forSignIn` If `true`, [oauth/authenticate](https://dev.twitter.com/oauth/reference/get/oauth/authenticate) endpoint is used instead of [oauth/authorize](https://dev.twitter.com/oauth/reference/get/oauth/authorize) (Default: `false`) * `forceLogin` Specify `force_login` (See [Twitter docs](https://dev.twitter.com/oauth/reference/get/oauth/authorize#parameters).) (Default: `false`) * `screenName` Specify `screen_name` (See [Twitter docs](https://dev.twitter.com/oauth/reference/get/oauth/authorize#parameters).) +* `openUrl` specify an alternative method of opening twitter auth (e.g. a web modal) * Returns: `Promise` of `{accessToken, accessTokenSecret, id, name}` * `accessToken` Access token From 7e20acb9d01f25ef4dd83f2478d3baaac025e079 Mon Sep 17 00:00:00 2001 From: kyle Date: Sat, 17 Mar 2018 17:40:49 +0000 Subject: [PATCH 3/3] support desktop --- src/stream/index.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/stream/index.js diff --git a/src/stream/index.js b/src/stream/index.js new file mode 100644 index 0000000..9912ecd --- /dev/null +++ b/src/stream/index.js @@ -0,0 +1,3 @@ +export default function stream() { + console.error(new Error('Streaming APIs are not supported on iOS.')); +}