Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android error when trying to perform login #22

Open
mancas opened this issue Oct 5, 2017 · 2 comments
Open

Android error when trying to perform login #22

mancas opened this issue Oct 5, 2017 · 2 comments

Comments

@mancas
Copy link

mancas commented Oct 5, 2017

Hi! First of all, thanks for this library!

I'm working in a new react native app with this configuration:

{
  "name": "Pikis",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native": "^4.0.0",
    "jest-expo": "~20.0.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "Root.js",
  "scripts": {
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^20.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz",
    "react-native-elements": "^0.17.0",
    "react-native-fbsdk": "^0.6.1",
    "react-native-linkedin-sdk": "^0.0.9",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^5.0.5",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0",
    "uuid": "^3.1.0"
  }
}

The library is linked and everything works fine until I try to log in: (on my button)

LinkedInSDK.signIn({
      // https://developer.linkedin.com/docs/oauth2

      // iOS (Required)
      // The "API Key" value generated when you registered your application.
      clientID: '<clientId>',

      // iOS (Required)
      clientSecret: '<secret>',

      // iOS (Required)
      // A unique string value of your choice that is hard to guess. Used to prevent CSRF.
      state: '<state_value>',

      // iOS, Android (Required)
      scopes: [
        'r_basicprofile',
        'r_emailaddress',
        'w_share'
      ],

      // iOS (Required)
      // The URI your users will be sent back to after authorization.  This value must match one of the defined OAuth 2.0 Redirect URLs in your application configuration.
      // e.g. https://www.example.com/auth/linkedin
      redirectUri: 'your_oauth2_redirect_url',
    }).then(result => console.info(result)).catch(error => console.error(error));

For some reason, when I accept permissions on LinkedIn app, it returns to mine but there is no token nor errors. I've also tried to add traces inside the library but seems that the login method does not exit via success nor error...

Any ideas?

Thanks!

@iuliuvisovan
Copy link

iuliuvisovan commented Nov 18, 2017

Exact same thing happening here, tried debugging the Java code but with no luck so far.. It seems that neither onAuthSuccess nor onAuthError get executed..

@iuliuvisovan
Copy link

iuliuvisovan commented Nov 21, 2017

I managed to solve it eventually. The problem is the "PACKAGE NAME & PACKAGE HASH" in your Linkedin dev app! They are crucial! I spent many many hours until I finally got it working, here's how:

  1. Open your android project in Android Studio.
  2. Select 'Build -> Generate signed APK...' (I think it needs to be release build, but not sure)
  3. After finishing, copy your generated APK in your JAVA JDK BIN FOLDER (C:/Program Files/Java/jdkx.x/bin)
  4. Open COMMAND LINE there. Run 'keytool -list -printcert -jarfile your-apk-name.apk'
  5. Copy the SHA1 value displayed there
  6. Converti it to base64 using this: http://tomeko.net/online_tools/hex_to_base64.php
  7. THIS IS YOUR PACKAGE HASH. Put it in your linkedin app together with your package name.
  8. Run 'adb install -r your-apk-name.apk' in your APK's folder while having your phone connected
  9. Stupid linkedin SDK doesn't return to your app without doing anything anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants