Very important! The module doesn't provide full stack communication with social networks API, it made just for auth.
- React Native >=
0.40.0
(use0.5
branch that works with previous versions of RN)
facebook
- FacebookSDK
twitter
- Accounts.framework and reverse auth (iOS)
- Install package via npm:
npm install react-native-social-auth
- Inside your code include JS part by adding
import SocialAuth from 'react-native-social-auth';
Perform platform specific setup - iOS - Android
SocialAuth.facebookPermissionsType.read
SocialAuth.facebookPermissionsType.write
SocialAuth.setFacebookApp({id: 'APP_ID', name: 'DISPLAY_NAME'});
permissions
(Array of strings)permissionsType
(one of facebookPermissionsType)
- resolved with
credentials
(object containsaccessToken
,userId
,hasWritePermissions
) - rejected with
error
(object containscode
andmessage
)
SocialAuth.getFacebookCredentials(["email", "user_friends"], SocialAuth.facebookPermissionsType.read)
.then((credentials) => console.log(credentials));
.catch((error) => console.log(error))
- resolved with
accounts
(array of objects like{username: "userName"}
) - rejected with
error
(object containscode
andmessage
)
SocialAuth.getTwitterSystemAccounts()
.then((accounts) => console.log(accounts))
.catch((error) => console.log(error));
-
username
(Twitter account user name without@
) -
reverseAuthResponse
(is a string that returns by twitter's api when we do the first part of reverse auth)- you can define
key
andsecret
of your twitter app in RNSocialAuthManager.m
#define twitterAppConsumerKey @"..." #define twitterAppConsumerSecret @"..."
- other option is that your server can perform the first part of reverse auth and send you back response of it.
It looks like this
Then you just pass it to the function as a second parameter
OAuth oauth_timestamp="...", oauth_signature="...", oauth_consumer_key="...", oauth_nonce="...", oauth_token="...", oauth_signature_method="HMAC-SHA1", oauth_version="1.0"
- you can define
- resolved with
credentials
(object containsoauthToken
,oauthTokenSecret
,userName
) - rejected with
error
(object containscode
andmessage
)
SocialAuth.getTwitterCredentials("dimkol")
.then((credentials) => console.log(credentials))
.catch((error) => console.log(error));
Just submit a pull request!
Code and documentation copyright 2015 Dmitriy Kolesnikov. Code released under the MIT license.