nraboy / ng-cordova-oauth

AngularJS oauth library for use with Apache Cordova projects
https://www.thepolyglotdeveloper.com
MIT License
456 stars 199 forks source link

Cordova Oauth linkedin error "Sign in flow was cancelled" #249

Closed jackmasi closed 8 years ago

jackmasi commented 8 years ago

I am following the Cordova Oauth procedure to get the access token, But after the login success i am always getting "Sign in flow was cancelled". I am using from android mobile. I register developer account in linkedin. Please help me to resolve the issues.

My Code:

$cordovaOauth.linkedin("75*****y", "b****_4", ["rbasicprofile"], "7****a").then(function(result) { alert("accesstoken result"); },function(error) { alert("accesstoken error "+error);

        });
nraboy commented 8 years ago

How did you make your configurations in the LinkedIn dashboard? My guess is that it is a configuration issue, as the oauth APIs have not changed.

jackmasi commented 8 years ago

i Just register and got the clientid and clientsecret information. Client ID: 75d8o3s1zzueiy Client Secret: bBAkSZSRBxNW0YM4

I checked all the Default Application Permissions r_basicprofile r_emailaddress rw_company_admin w_share

In the OAuth 2.0 i just add the Authorized Redirect URL is "http://localhost/callback"

finally i click update. This is the configuration done by me. Other than this i didnt changed nothing. But error throwing as "the sign in flow was cancelled"

ghost commented 8 years ago

I am getting the same error and the configuration are same as @jackmasi and I found out LinkedIn doesn't need a Client Secret Id for authentication so why are we adding it https://developer.linkedin.com/docs/oauth2

nraboy commented 8 years ago

I just tested and it works fine for me:

linkedin-oauth

This goes in combination with the following code:

$scope.linkedin = function() {
        $cordovaOauth.linkedin("CLIENT_ID_HERE", "CLIENT_SECRET_HERE", ["r_basicprofile", "r_emailaddress"], "nraboy-test").then(function(result) {
            console.log("RESPONSE -> " + JSON.stringify(result));
        }, function(error) {
            console.log("ERROR -> " + JSON.stringify(error));
        });
    }

To answer @priya-sookshum-labs question, we are using a secret because when I created the library, LinkedIn only supported explicit grants. Are you saying LinkedIn now supports implicit grants?

I am closing this ticket as there is no reproducible problem.

Best,

ghost commented 8 years ago

@nraboy Thank you for your time and work, my problem is solved I created a new app in LinkedIn and used this combination ["r_basicprofile", "r_emailaddress"] , before I tested on ["r_basicprofile"] and ["r_basicprofile", "r_emailaddress", rw_company_admin] and using the combination you provided code working now. About the implicit grants Linked I read the doc so linked didn't mention anywhere that the Client Secret is required so I am not sure, was just curious as a beginner anyway thank you so much for your time :)

nraboy commented 8 years ago

Implicit grants (client id only) are always preferred for JavaScript applications. Not all providers offer this though.

jackmasi commented 8 years ago

@priya-sookshum-labs I just followed your process. But again I am getting same error like "Sign in flow was cancelled". Actually i am using from my android mobile. I don't know may i missed any configuration during this process. So please give the solution for this. My Steps:

  1. I could create the new app in LinkedIn developer. And I got the client Id and Client secret.
  2. I added redirect uri. And i click update.
  3. Now i check from my android mobile. Now i am getting the error
ghost commented 8 years ago

@jackmasi This is my code. var linkedinlogin = function(){ $ionicLoading.show({template: 'Loading...'}); $cordovaOauth.linkedin(LinkedIn_Client_id, LinkedIn_Client_Secret, ['r_basicprofile', "r_emailaddress"], 'oauth-login-test') .then(function(result) { console.log("RESPONSE -> " + JSON.stringify(result)); $ionicLoading.hide(); $state.go("tab"); },function(error){ console.error("Unable to connect to Linkedin"); console.log("ERROR -> " + JSON.stringify(error)); $ionicLoading.hide(); $state.go("login"); }); };

Please match the linkedin project details linkedin

Also Check the client id and secret you are passing is correct or have no spaces and bdw I am also running it on my android device.

jackmasi commented 8 years ago

I am following your comments. But still the error is continuing.

jackmasi commented 8 years ago

@priya-sookshum-labs I am following your steps. But still the error is occuring. ln reg

And My Code is

$cordovaOauth.linkedin('755nl2m4ujzjir', 'aZlUWx7DaDgRFqF1', ['r_basicprofile', 'r_emailaddress'], 'guyky-test890') .then(function(result) { alert("RESPONSE -> " + JSON.stringify(result)); $ionicLoading.hide(); }, function(error) { alert("ERROR -> " + JSON.stringify(error)); $ionicLoading.hide(); });

I assume any configuration is missing where i register the developer account or need to do specific for mobile devices. So please let me know

ghost commented 8 years ago

@jackmasi Can't say What is wrong with configuration without looking at it, but did you follow this guide https://developer.linkedin.com/docs/oauth2 It might help you set the correct configuration. their is no special configuration for mobile devices, just follow the guide and please check if you have correct plugins.

ghost commented 8 years ago

@jackmasi I just ran my code with your client id and secret and I am successfully getting the access token , so looks like your configuration is correct, try adding inappbrowser plugin and platform again

jackmasi commented 8 years ago

may i know which android version is using mobile as well as android sdk manager. And which version inappbrowser plugin is used for developing

ghost commented 8 years ago

@jackmasi android mobile version : v 4.4.2, android:minSdkVersion="16" android:targetSdkVersion="23"

Cordova Plugin list

cordova-plugin-console 1.0.3 "Console" cordova-plugin-device 1.1.2 "Device" cordova-plugin-inappbrowser 1.4.1-dev "InAppBrowser" cordova-plugin-splashscreen 3.2.2 "Splashscreen" cordova-plugin-statusbar 2.1.3 "StatusBar" cordova-plugin-whitelist 1.2.2 "Whitelist" ionic-plugin-keyboard 2.2.0 "Keyboard"

Ionic info

Cordova CLI: 6.1.1 Gulp version: CLI version 3.9.1 Gulp local: Ionic Version: 1.3.0 Ionic CLI Version: 1.7.14 Ionic App Lib Version: 0.7.0 OS: Node Version: v5.11.0

nooranalytics commented 8 years ago

hello,

whats the solution to this issue? I have tried everything everyone suggested but it doesnt work

jackmasi commented 7 years ago

Finally I got the accesstoken using this procedure. Thanks @nraboy

nooranalytics commented 7 years ago

@jackmasi can you please tell me what you did to solve this issue ? I am still confused