Ever since Jaxl library first introduced support for X-FACEBOOK-PLATFORM XMPP authentication mechanism, it has changed significantly. Also, Google Talk now supports OAuth 2.0 Authorization, an XMPP extension to allow users to log in using OAuth 2.0 credentials.
Both these mechanisms are a big win for XMPP developers, since real-time conversation experience can now be provided to their application users without asking them for their passwords. In this blog post, I will demonstrate how to perform X-FACEBOOK-PLATFORM and X-OAUTH2 XMPP authentication mechanism using Jaxl v3.x PHP Library.
X-FACEBOOK-PLATFORM XMPP Authentication
Here is a quick guide on how to perform X-FACEBOOK-PLATFORM XMPP authentication using xfacebook_platform_client.php which comes bundled with Jaxl v3.x examples:
- Visit Facebook Developer Apps page and register your application
- Once registered, visit access token tool to get required parameters to perform X-FACEBOOK-PLATFORM authentication
- Click on the debug button next to User Token and make sure xmpp_login is one of the extended permissions (scope)
- Enter downloaded Jaxl library folder and run from command line as follows:
$ php examples/xfacebook_platform_client.php fb_user_id_or_username fb_app_key fb_access_token
You can now take the source code of xfacebook_platform_client.php and customize it for your application needs.
Google Talk X-OAUTH2 XMPP Authentication
Here is a quick guide on how to perform Google Talk X-OAUTH2 XMPP authentication using xoauth2_gtalk_client.php which comes bundled with Jaxl v3.x examples:
- Visit Google OAuth Playground and input
https://www.googleapis.com/auth/googletalk
as the required scope. Press “Authorize API” and then “Allow Access” button on the redirected page - In step 2, simply press “Exchange authorize code for tokens” and copy the access token
- Enter downloaded Jaxl library folder and run from command line as follows:
$ php examples/xoauth2_gtalk_client.php username@gmail.com access_token
You can now take the source code of xoauth2_gtalk_client.php and customize it for your application needs.
Wasn’t that simple