Using OAuth2 to login with Linkedin

61 views
Skip to first unread message

nick.m...@gmail.com

unread,
Apr 22, 2015, 1:02:51 AM4/22/15
to codenameone...@googlegroups.com

I'm trying to add a Login with linked in option to the app I'm currently working on using the OAuth2 object but not having much luck.

I've been trying to follow the api guide to OAuth2 authentication from here: https://developer.linkedin.com/docs/oauth2

but I'm just getting a blank screen.

My CN1 java looks like this:
Oauth2 auth2 = new Oauth2("https://www.linkedin.com/uas/oauth2/authorization",
               
"{Consumer Key}",
               
"",
               
"r_fullprofile%20r_emailaddress",
               
"https://www.linkedin.com/uas/oauth2/accessToken",
               
"{Consumer Secret}");
       
Oauth2.setBackToParent(true);
        auth2
.showAuthentication(new ActionListener() {
           
           
public void actionPerformed(ActionEvent evt) {
               
if (evt.getSource() instanceof String) {
                   
String token = (String) evt.getSource();
                   
String expires = Oauth2.getExpires();
                   
               
} else {
                   
Exception err = (Exception) evt.getSource();
                    err
.printStackTrace();
                   
Dialog.show("Error", "An error occurred while logging in: " + err, "OK", null);
               
}
           
}
       
});...

none of the code in the actionPerformed method is being fired.

What I'm not sure about is the redirect_uri. In the Facebook connect code I see that this is just www.codenameone.com so I assumed it wouldn't effect the outcome, but it seems to be completely bypassing the login and going directly to whatever this page is. Or if it's not the same as the one in the back-end I'm seeing an error.

Is this because I'm running it in the simulator?
or is it something specific to Linkedin?

What am I doing wrong here?

is there a more comprehensive guide on how the OAuth2 codenameone object works?


IDE: NetBeans
Simulator

Shai Almog

unread,
Apr 22, 2015, 11:21:47 AM4/22/15
to codenameone...@googlegroups.com, nick.m...@gmail.com
Its possible you passed authorization once and the server just redirects you to the next page implicitly without prompting.
You can check out a sample of the API usage in the dropbox integration: http://codenameone.com/cn1libs.html
Reply all
Reply to author
Forward
0 new messages