How to Create a Microsoft Login Button using PHP – With Integration tip
You can login with major websites like Microsoft, Google, Facebook and Twitter into some websites using a protocol called “OAuth” it is an authentication app that controls access to a website using well known and trusted sites to make login faster and secure. It a subtle form of collaboration and partnership between the participating websites.
What is OAuth?
class="_Tgc">OAuth is an open standard to authorization.title="OAuth" href="http://en.wikipedia.org/wiki/OAuth" target="_blank"> OAuth provides client applications a ‘secure delegated access’ to server resources on behalf of a resource owner. It specifies a process for resource owners to authorize third-party access to their server resources without sharing their credentials.
OAuth Types
After OAuth 1.0 the OAuth 2.0 is the next evolution of the OAuth protocol and is not backwards compatible with OAuth 1.0. OAuth 2.0 focuses on client developer simplicity while providing specific authorization flows for web applications, desktop applications, mobile phones, and living room devices. The specification and associated RFCs are developed by the IETF OAuth WG; the main framework was published in October 2012. (It was expected to be finalized by the end of 2010, according to Eran Hammer. However, due to discordant views about the evolution of OAuth, Hammer left the working group.
href="https://harkingbade.s3.amazonaws.com/wp-content/uploads/2014/12/27091242/microsoft-account-login-button.png">class="aligncenter size-full wp-image-1929" src="https://harkingbade.s3.amazonaws.com/wp-content/uploads/2014/12/27091242/microsoft-account-login-button.png" alt="microsoft login button" width="640" height="396" />
What is Microsoft Log-In?
Microsoft Log-in means asking user to grant access to his/her Microsoft live information like email id, username etc. Once your website has been granted access and has all these information about the user it can allow the users to access protected pages on your website.
Setting up Directory and Files
Before we get started you need to create a PHP file named redirect.php. Place this file anywhere in your webspace.
Creating a Microsoft App
If your website is allowing login using Microsoft then your website is considered as an Microsoft app. So you have your website ready now its time to register you website as a Microsoft app. Follow this steps to create a Microsoft app:
- Visit href="https://account.live.com/developers/applications" target="_blank" rel="nofollow external">Microsoft apps page.
- Now create a Microsoft app
- Select API Settings and for redirect URL pass URL pointing to the redirect.php file.
- You can find the Client ID and Client Secret under App Settings
Creating Login with Microsoft Button
When user clicks on Login button you need to run this code to redirect user to Microsoft Live website so that user can grant permission to your app to access their informationid="highlighter_890494" class="syntaxhighlighter ">class="lines">
class="number"> | class="content"> |
class="number"> | class="content"> |
class="number"> | class="content"> |
class="number"> | class="content"> |
Scopes represent the list of permissions for the app. You need to pass a comma separated list of permissions. href="http://msdn.microsoft.com/en-us/library/hh243646.aspx" target="_blank" rel="nofollow external">List of all scopes.
Populate the $client_id
and $redirect_uri
variables.
Once user has given access to the app, Microsoft will redirect user back to the redirect URI. Now you need to retrieve an access token which acts like a permission to get user information.
In the redirect.php file you can retrieve access token by running this codeclass="lines">class="line alt1">
class="number"> | class="content"> |
class="number"> | class="content"> |
0 comments:
Post a Comment