a react native instagram login component (support android & ios). Pull requests are welcome!
a react native instagram login component (support android & ios). Pull requests are welcome!
react-native-instagram-login version 2 switches to the Instagram Graph API.
If you want to use old version 1, please read docs
npm install react-native-instagram-login react-native-webview --saveThen link the native iOS package:
npx pod-installThen go to Instagram> Basic Display> Instagram App ID field
This is going to give you an access_token, which one can be used on the new Graph Api, go to https://developers.facebook.com/docs/instagram-basic-display-api/guides/getting-profiles-and-media for docs.
……| Property | Type | Description |
|---|---|---|
| appId | PropTypes.string | Instagram client_id |
| appSecret | PropTypes.string | Instagram client_secret |
| responseType | PropTypes.string | 'code' or 'token', default 'code' |
| scopes | PropTypes.array | Login Permissions, default ['user_profile', 'user_media'] |
| redirectUrl | PropTypes.string | Your redirectUrl |
| incognito | PropTypes.boolean | Incognito true/false |
| onLoginSuccess | PropTypes.func | Function will be call back on success |
| onLoginFailure | PropTypes.func | Function will be call back on error |
| onClose | PropTypes.func | Function will be call back on close modal |
| modalVisible | PropTypes.bool | true or false |
| renderClose | PropTypes.func | Render function for customize close button |
| containerStyle | PropTypes.object | Customize container style |
| wrapperStyle | PropTypes.object | Customize wrapper style |
| closeStyle | PropTypes.object | Customize close style |
| language | PropTypes.string | Override language of modal,alpha-2 eg:"es","tr" etc. |
If you dont want to expose appSecret on the client, you dont need to pass appSecret props on client. And onLoginSuccess will callback a code.
On your server (Backend) you have to call an api https://api.instagram.com/oauth/access_token with method post to exchange the code for a token, and params:
client_id: your-app-id
client_secret: your-app-secret
grant_type: 'authorization_code'
redirect_uri: your-redirect-url
code: code-get-from-onLoginSuccess-propsThe response will look like this:
{
"access_token": "IGQVJ...",
"user_id": 17841405793187218
}To logout use clear cookies by using https://github.com/react-native-community/cookies
import CookieManager from '@react-native-community/cookies';
logout() {
CookieManager.clearAll(true)
.then((res) => {
console.log('CookieManager.clearAll =>', res);
this.setState({ token: '' })
});
}Special thanks @AlbertoIHP for v2.
This project exists thanks to all the people who contribute. [Contribute].
Pull requests are welcome!
No open issues yet, or sync has not completed.