2.1.1 • Published 5 years ago

react-native-linkedin v2.1.1

Weekly downloads
1,080
License
MIT
Repository
github
Last release
5 years ago

Benefits

  • Light: No need to link a native library like others alternatives
  • Simple: Get the token and the expires, you handle your own login with the access_token
  • Sure: open-source
  • Almost readable & understandable code: JavaScript & React

Installation

$ yarn add react-native-linkedin

Security

Please note that you should give your linkedin client id but not your secret key to this component. You should be aware that key can be found if you store it directly to your code. I strongly recommend to not declare client secret key on your code but found a way to keep it secret

  <LinkedInModal
    shouldGetAccessToken={false}
    clientSecret={null}
    clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
    redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
    onSuccess={{ authentication_code } => console.log(`Post this ${authentication_code} to your server.`)}
  />

Example

// See ./App.tsx file for details
import React from 'react'
import { StyleSheet, View } from 'react-native'

import LinkedInModal from 'react-native-linkedin'

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    justifyContent: 'center',
    alignItems: 'center',
  },
})

export default class AppContainer extends React.Component {
  linkedRef = React.createRef<LinkedInModal>()
  render() {
    return (
      <View style={styles.container}>
        <LinkedInModal
          ref={this.linkedRef}
          clientID="[ Your client id from https://www.linkedin.com/developer/apps ]"
          clientSecret="[ Your client secret from https://www.linkedin.com/developer/apps ]"
          redirectUri="[ Your redirect uri set into https://www.linkedin.com/developer/apps ]"
          onSuccess={token => console.log(token)}
        />
        <Button title="Log Out" onPress={this.linkedRef.current.logoutAsync()} />
      </View>
    )
  }
}

Props

NameTypeRequiredDefaultDescription
clientIDstringrequiredYour client id
clientSecretstringuse shouldGetAccessToken={false} and read authorization_code onSuccess returnShould not be stored in app WARNING! Your client secret
redirectUristringrequiredYour redirectUri
onSuccessfunctionrequiredFunction will be call back on success
authStatestringoptionalrequire('uuid').v4()The state of auth, to be more secure
onErrorfunctionoptionalconsole.error(err)Function will be call back on error
onClosefunctionoptionalFunction will be call back on close modal
onOpenfunctionoptionalFunction will be call back on open modal
onSignInfunctionoptionalFunction will be call back when the user sign in
permissionsarrayoptional'r_liteprofile', 'r_emailaddress'The LinkedIn access token permissions
renderButtonfunctionoptionalRender function for customize LinkedIn button
renderClosefunctionoptionalRender function for customize close button
linkTextstringoptional'Login with LinkedIn'Link label
containerStyleViewPropTypes.styleoptionalCustomize container style
wrapperStyleViewPropTypes.styleoptionalCustomize wrapper style
closeStyleViewPropTypes.styleoptionalCustomize close style
animationTypeModal.propTypes.animationTypeoptionalfadeCustomize animationType style: 'none', 'slide' or 'fade'
shouldGetAccessTokenbooloptionaltrueSet to false to receive the 'authorization code' rather then the 'access token'

Contribution

PRs are welcome!

FAQ

Is it supported and tested both on android and iOS?

YES

Other questions

Feel free to contact me or create an issue

Alternatives

Hire an expert!

Looking for a ReactNative freelance expert with more than 12 years of experience? Contact me from my website!

Licence

MIT

made with ♥

2.1.1

5 years ago

2.1.0

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.2

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

7 years ago

1.1.0

7 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.29

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago