All Projects → hungdev → React Native Instagram Login

hungdev / React Native Instagram Login

a react native instagram login component (support android & ios). Pull requests are welcome!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Instagram Login

Oauth
🔗 OAuth 2.0 implementation for various providers in one place.
Stars: ✭ 336 (+141.73%)
Mutual labels:  authentication, oauth, instagram
Vue Authenticate
Simple Vue.js authentication library
Stars: ✭ 1,350 (+871.22%)
Mutual labels:  authentication, oauth, auth
instagram-oauth-nodejs-server
Node.js server for Intagram-API OAuth purpose.
Stars: ✭ 12 (-91.37%)
Mutual labels:  instagram, oauth, instagram-api
Angular Token
🔑 Token based authentication service for Angular with interceptor and multi-user support. Works best with devise token auth for Rails. Example:
Stars: ✭ 376 (+170.5%)
Mutual labels:  authentication, oauth, auth
Fosite
Extensible security first OAuth 2.0 and OpenID Connect SDK for Go.
Stars: ✭ 1,738 (+1150.36%)
Mutual labels:  authentication, oauth, auth
Swiftinstagram
Instagram API client written in Swift
Stars: ✭ 570 (+310.07%)
Mutual labels:  instagram-api, authentication, instagram
Flask simplelogin
Simple Login - Login Extension for Flask - maintainer @cuducos
Stars: ✭ 133 (-4.32%)
Mutual labels:  authentication, auth
Warden Github Rails
Use GitHub as authorization and more. Use organizations and teams as means of authorization by simply wrapping your rails routes in a block. Also useful to get a user's details through OAuth.
Stars: ✭ 100 (-28.06%)
Mutual labels:  authentication, oauth
Instagram Bot Dm
Instagram bot to send direct messages
Stars: ✭ 101 (-27.34%)
Mutual labels:  instagram-api, instagram
Mern Boilerplate
Fullstack boilerplate with React, Redux, Express, Mongoose, Passport Local, JWT, Facebook and Google OAuth out of the box.
Stars: ✭ 112 (-19.42%)
Mutual labels:  authentication, oauth
Auth
Official authentication provider for Adonis framework
Stars: ✭ 110 (-20.86%)
Mutual labels:  authentication, auth
Graphql Directive Auth
GraphQL directive for handling auth
Stars: ✭ 120 (-13.67%)
Mutual labels:  authentication, auth
Instagram api gem
A Ruby wrapper for the Instagram API
Stars: ✭ 100 (-28.06%)
Mutual labels:  instagram-api, instagram
Swiftagram
A modern Swift wrapper for Instagram Private API.
Stars: ✭ 100 (-28.06%)
Mutual labels:  instagram-api, instagram
Omniauth Instagram
OmniAuth strategy for Instagram.
Stars: ✭ 103 (-25.9%)
Mutual labels:  authentication, instagram
Sentinel
A framework agnostic authentication & authorization system.
Stars: ✭ 1,354 (+874.1%)
Mutual labels:  authentication, auth
Spring Webmvc Pac4j
Security library for Spring Web MVC: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 110 (-20.86%)
Mutual labels:  authentication, oauth
Assent
Multi-provider framework in Elixir
Stars: ✭ 126 (-9.35%)
Mutual labels:  oauth, instagram
Inwidget
inWidget - free Instagram widget for your website. Allows you to show photos from an Instagram account, by hashtags and more.
Stars: ✭ 132 (-5.04%)
Mutual labels:  instagram-api, instagram
Instagram ssl pinning
Bypassing SSL Pinning in Instagram Android App
Stars: ✭ 135 (-2.88%)
Mutual labels:  instagram-api, instagram

React Native Instagram login

npm version npm downloads

IMPORTANT NOTES:

react-native-instagram-login version 2 switches to the Instagram Graph API.

If you want to use old version 1, please read docs

Install

npm install react-native-instagram-login react-native-webview --save

Then link the native iOS package:

npx pod-install

Setup (React Native < 0.60.0):

Automatic (recommended)

react-native link

with manual, see more

How to get appId, appSecret of instagram?

Simple setup, you only need to complete step 3.

Then 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.

Usage:

import React, { Component } from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import InstagramLogin from 'react-native-instagram-login';
import CookieManager from '@react-native-community/cookies';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      token: '',
    };
  }

  setIgToken = (data) => {
    console.log('data', data)
    this.setState({ token: data.access_token })
  }

  onClear() {
    CookieManager.clearAll(true)
      .then((res) => {
        this.setState({ token: null })
      });
  }
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <TouchableOpacity
          style={styles.btn}
          onPress={() => this.instagramLogin.show()}>
          <Text style={{ color: 'white', textAlign: 'center' }}>Login now</Text>
        </TouchableOpacity>
        <TouchableOpacity
          style={[styles.btn, { marginTop: 10, backgroundColor: 'green' }]}
          onPress={() => this.onClear()}>
          <Text style={{ color: 'white', textAlign: 'center' }}>Logout</Text>
        </TouchableOpacity>
        <Text style={{ margin: 10 }}>Token: {this.state.token}</Text>
        {this.state.failure && (
          <View>
            <Text style={{ margin: 10 }}>
              failure: {JSON.stringify(this.state.failure)}
            </Text>
          </View>
        )}
        <InstagramLogin
          ref={ref => (this.instagramLogin = ref)}
          appId='your-app-id'
          appSecret='your-app-secret'
          redirectUrl='your-redirect-Url'
          scopes={['user_profile', 'user_media']}
          onLoginSuccess={this.setIgToken}
          onLoginFailure={(data) => console.log(data)}
        />
      </View>
    );
  }
}


const styles = StyleSheet.create({
  btn: {
    borderRadius: 5,
    backgroundColor: 'orange',
    height: 30,
    width: 100,
    justifyContent: 'center',
    alignItems: 'center',
  }
});


Props

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
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

Server side explicit: Discuss here

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-props

For example

The response will look like this:

{
  "access_token": "IGQVJ...",
  "user_id": 17841405793187218
}

Logout

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: '' })
      });
  }

Contributing

Special thanks @AlbertoIHP for v2.

This project exists thanks to all the people who contribute. [Contribute].

Pull request

Pull requests are welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].