Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/oauth/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Linking} from 'react-native';
import {Linking,Modal} from 'react-native';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modal looks like not used. Could be removed?


import URLSearchParams from 'url-search-params';

Expand Down Expand Up @@ -63,16 +63,18 @@ 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(
tokens,
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 (
Expand Down
3 changes: 3 additions & 0 deletions src/stream/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function stream() {
console.error(new Error('Streaming APIs are not supported on iOS.'));
}