Foren

LinkedIn authentication from Custom Portlet

thumbnail
Anindya Mallik, geändert vor 8 Jahren.

LinkedIn authentication from Custom Portlet

Junior Member Beiträge: 82 Beitrittsdatum: 15.01.13 Neueste Beiträge
Hi All,

I have created one custom portlet from where user will be authenticated in LinkedIn. Already I have done that in normal J2EE application using servlet and jsp. But for Liferay I am facing one isseue.

Here is my part of jsp:
<div id="ConnectLinkedIn">
<h4>Connect your LinkedIn Account</h4>
<a href="https://www.linkedin.com/uas/oauth2/authorization?response_type=code&amp;client_id=XXXXXXXXXXXX&amp;redirect_uri=http%3A%2F%2Flocalhost%2Fweb%2Fguest%2Fnetworks&amp;state=DCEeFWf45A53sdfKef424"><div id="LinkedInButton"></div></a>
</div>


After the authentication I am getting code and state in url, as linkedIn provides those as parameters in url, but then how do I hold those parameters? So that I can proceed to the next.

Please help me. Any help would be greatly appreciated.
thumbnail
Miroslav Ligas, geändert vor 8 Jahren.

RE: LinkedIn authentication from Custom Portlet

Regular Member Beiträge: 152 Beitrittsdatum: 29.07.14 Neueste Beiträge
You may use Custom (Expando) Attributes for User if you need to keep the values permanently otherwise use session.

You may also want to have a look at the google login hook https://github.com/liferay/liferay-plugins/tree/master/hooks/google-login-hook. Google also uses OAuth so the principles are the same.
thumbnail
Anindya Mallik, geändert vor 8 Jahren.

RE: LinkedIn authentication from Custom Portlet

Junior Member Beiträge: 82 Beitrittsdatum: 15.01.13 Neueste Beiträge
Miroslav Ligas:
You may use Custom (Expando) Attributes for User if you need to keep the values permanently otherwise use session.

You may also want to have a look at the google login hook https://github.com/liferay/liferay-plugins/tree/master/hooks/google-login-hook. Google also uses OAuth so the principles are the same.



Hi Miroslav,

Many thanks for your reply. But one thing I want to know I can use session one I get those values, but how to collect that?
thumbnail
Neha Goyal, geändert vor 8 Jahren.

RE: LinkedIn authentication from Custom Portlet

Regular Member Beiträge: 121 Beitrittsdatum: 14.05.13 Neueste Beiträge
Anindya Mallik:
Miroslav Ligas:
You may use Custom (Expando) Attributes for User if you need to keep the values permanently otherwise use session.

You may also want to have a look at the google login hook https://github.com/liferay/liferay-plugins/tree/master/hooks/google-login-hook. Google also uses OAuth so the principles are the same.



Hi Miroslav,

Many thanks for your reply. But one thing I want to know I can use session one I get those values, but how to collect that?



You can set those values as attribute in session object like session.setAttribute("xxx",xxx) and then you can get that value with session.getAttribute("xxx").
Please correct me if i am wrong.
thumbnail
Anindya Mallik, geändert vor 8 Jahren.

RE: LinkedIn authentication from Custom Portlet

Junior Member Beiträge: 82 Beitrittsdatum: 15.01.13 Neueste Beiträge
Neha Goyal:
Anindya Mallik:
Miroslav Ligas:
You may use Custom (Expando) Attributes for User if you need to keep the values permanently otherwise use session.

You may also want to have a look at the google login hook https://github.com/liferay/liferay-plugins/tree/master/hooks/google-login-hook. Google also uses OAuth so the principles are the same.



Hi Miroslav,

Many thanks for your reply. But one thing I want to know I can use session one I get those values, but how to collect that?



You can set those values as attribute in session object like session.setAttribute("xxx",xxx) and then you can get that value with session.getAttribute("xxx").
Please correct me if i am wrong.


Hi Neha,

Thanks for your reply. Yes I can store it into session, but before that I have to capture that. How do I capture those values?
thumbnail
Miroslav Ligas, geändert vor 8 Jahren.

RE: LinkedIn authentication from Custom Portlet

Regular Member Beiträge: 152 Beitrittsdatum: 29.07.14 Neueste Beiträge
The values should be parameters of the callback form LinkedIn. You need to have a custom action that waits for the callback form LinkedIn and in that action you can access and store the parameters.
I haven't worked with LinkedIn only with twitter and google but I think it's the same principle.

The flow should be something like this. If you ask LinkedIn to verify a user you send a request and on LinkedIn side you define where it should respond in a separate call. In that call it will provide some tokens that need to be again verified in another call against LinkedIn. After a positive response you can login user.

Edit: also have a look here https://www.liferay.com/community/forums/-/message_boards/message/54051600