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

linkedin sign in issue #298

Open cheekuji opened 8 years ago

cheekuji commented 8 years ago

I was able to bring up the login page for linked in but when I hit cancel instead of submitting the credentials I get the following message: {"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : authorization code not found","error":"invalid_request"}

Another problem is I can only signin via android. Whenever I use iphone I ge the same message above: {"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : authorization code not found","error":"invalid_request"}

nraboy commented 8 years ago

A few questions:

  1. Are you using the latest version of the library?
  2. Have you configured LinkedIn via the LinkedIn dashboard to be a web application, not Android and iOS?
  3. Have you provided all the necessary information in the command (state, client id, etc.)?

Best,

cheekuji commented 8 years ago

I am using latest version of ngcordova Yes I have, I can login via Android. All information is there.

Even with android I can see a page not found error for a split second and it goes away for ios I jiust cannot login at all.

From xcode logs I see this error: webView:didFailLoadWithError - -1004: Could not connect to the server.

cheekuji commented 8 years ago

I update the in app browser now I cannot login at all. I get this error: The sign in flow was canceled

nraboy commented 8 years ago

Are you using ng-cordova or ng-cordova-oauth? They are not the same. My library, ng-cordova-oauth, has no affiliation with what Ionic has produced.

On iOS you need to enable ATS. Because LinkedIn uses explicit grants you will always see for a moment an error screen for both Android and iOS. Only way to prevent this is to host your own redirect url.

AdrienDC commented 7 years ago

Got the same error "The sign in flow was canceled" since Angular 1.6.X. Works like a charm with Angular 1.5.11 and InAppBrowser 1.7.0

nraboy commented 7 years ago

Is this still an issue?

AdrienDC commented 7 years ago

Yes still

DhavalW commented 7 years ago

+1 facing the issue 'Sign in flow was cancelled'

DhavalW commented 7 years ago

@nraboy did some digging and found the problem on line 1173. At least for the linkedIn login.

      `var browserRef = window.cordova.InAppBrowser.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&scope=' + appScope.join(" ") + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');

`

I removed theappScope.join() bit and changed it to

    `  var browserRef = window.cordova.InAppBrowser.open('https://www.linkedin.com/uas/oauth2/authorization?client_id=' + clientId + '&redirect_uri=' + redirect_uri + '&response_type=code&state=' + state, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes');

`

Now it works fine. Returns a valid token, though there's brief & ugly error page that flickers just before it closes.

Does this have anything to do with the fact that you need URL encoded strings for the scope ?

nraboy commented 7 years ago

It could be the reason.

You do need scope otherwise you cannot define the permissions which will lead to other problems. Even though it worked for you, I'm sure you'll run into issues without the scope.

In terms of the flicker, it is because it is an explicit grant which is two step (get code and request access token) rather than an implicit grant (request access token). It is a race condition. You can make it a little more attractive by overriding the localhost with a real website.

I'm open to pull requests if you think you have a fix to all this.

DhavalW commented 7 years ago

Fair enough. LinkedIn applies the default permission for apps when you don't specify them. That's worked for me so far.

Facebook fails for me anyway, since it expects that you make requests from explicitly whitelisted domains, as specified in advance in the developer dashboard. But my implementation is from client side mobile apps (hybrid), which have varying IPs. So I'm not sure how'd I'd go about it for now.

On 30 September 2017 at 01:52, Nic Raboy notifications@github.com wrote:

It could be the reason.

You do need scope otherwise you cannot define the permissions which will lead to other problems. Even though it worked for you, I'm sure you'll run into issues without the scope.

In terms of the flicker, it is because it is an explicit grant which is two step (get code and request access token) rather than an implicit grant (request access token). It is a race condition. You can make it a little more attractive by overriding the localhost with a real website.

I'm open to pull requests if you think you have a fix to all this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nraboy/ng-cordova-oauth/issues/298#issuecomment-333229542, or mute the thread https://github.com/notifications/unsubscribe-auth/AOK1-KLQfJGNOawBHEakgLwZQYEKCt7zks5snVF3gaJpZM4KkNMU .