Friday, 14 December 2012

The Login System 1.0


In this module
- users can log in your website using their Facebook / Twitter / Google / Yahoo / Instagram / Google Plus account.
- user account details will be available in the session and displayed on front end.
- has logout facility and uses Java servlets.






How to install:

The download pack contains the complete project structure with the sample war file that I have deployed in my live demo.

1. For Fb Login - Create a Facebook Application

Details on creating Fb Application refer my: Facebook Login Post

2. For Twitter login - Create a Twitter Application

Details on creating Twitter Application refer my: Twitter Login Post

3. For Google Plus login - Enable Google+ API service

Details on registration with Google Plus refer my: Google Plus Authentication Post

4. For Instagram login - Create an Instagram Application

Details on creating Instagram Application refer my: Instagram Login Post

5. For Twitter Login - Adjust Server Timezone

Make sure your application server timezone and the Twitter server timezone are in sync. Now this can be tricky. Generally the Twitter Oauth servers are in sync with GMT/UTC time. So if you have access just set your server time to GMT+0 timezone.

I used a Jboss app server in Linux environment and did not have permissions to update server time. So I used the command export _JAVA_OPTIONS="-Duser.timezone=Europe/London" that brings Jboss server time to GMT timezone. (Restart Jboss after executing the command)

6. Web.xml (Input variables)

Specify the GooglePlus ClientId and GooglePlus ClientSecret from your GooglePlus application in your web.xml
Also the GooglePlus Additional Permissions are mentioned here. Specify the Instagram ClientId and Instagram ClientSecret from your Instagram application in your web.xml
Also the Instagram Additional Permissions are mentioned here.



Specify the Twitter ConsumerKey and Twitter ConsumerSecret from your Twitter application in your web.xml
Specify the Facebook AppId and Facebook AppSecret from your Fb application in your web.xml
Also the additional permissions for facebook login are mentioned here. You may update these permissions as required.



After successful login welcome.jsp will be shown to the user.


7. Welcome.jsp (Output variables)

The user account details will be available as session attributes in welcome.jsp

If the user logged in using Facebook, then the object fbUser that contains user details will be available in the session.


If the user logged in using Twitter, then the object twitterUser containing user details will be available in the session.


If the user logged in using Google or Yahoo, then the object gyUser containing user details will be available in the session.


If the user logged in using Instagram, then the object instagramUser containing user details will be available in the session.


If the user logged in using Google Plus, then the object googlePlusUser containing user details will be available in the session.


You may write your own display code instead, as required.

Let me know if you face any issues.
Thanks!

1 comment:

  1. when ever i access the google account i always see this error ... Invalid URL or URL mismatch ....

    ReplyDelete