Login with Microsoft Live Oauth Connect in PHP

I had already covered Facebook and Google Oauth Connect.In this tutorial i will tell you How to Login with Microsoft Live Oauth Connect in PHP.
Login with Microsoft Live Oauth Connect in PHP

View DemoDownload

Step 1:Create a Microsoft Application.
Step 2: Download our file and go to config.php

$clientId = '*************'; //Your Microsoft App Client ID
$clientSecret = '****************'; //Your Microsoft App Client ID

$redirectUriPath = "http://mycodingtricks.com/demo/oauth/login-with-microsoft-live-oauth-connect-in-php/oauth2Callback.php";    // This is the url that the client browser will be redirected to after authentication
$loggedInUrl = "http://mycodingtricks.com/demo/oauth/login-with-microsoft-live-oauth-connect-in-php/index.php"; //This is the url where user will be redirected when logged in

$scope = "wl.basic wl.emails wl.birthday wl.signin wl.offline_access";//For further scopes go to http://msdn.microsoft.com/en-us/library/hh243646.aspx

Edit the file.Add your client id and client secret of your Microsoft App
Step 3: Add the Login url to your webpage.

<a href="http://Your-Website.com/login_with_microsoft.php">Login with Microsoft</a>

Add the login_with_microsoft.php link in your page.
Step 4: Edit the logged in page(index.php).

<?php
session_start();
if(!isset($_SESSION['userdata']))
{
    /* User Logged Out Code goes here */
    $content = '<a href="login_with_microsoft.php">Login with Microsoft</a>';
}
else
{
    /* User Logged in code goes here */
    $content = $_SESSION['userdata'];
}
?>

View DemoDownload

Helpful Links

Please don’t forget to share this article and subscribe us through email to get the latest updates via email.

Note: If you have any Question/Recommendation then comment below.

Shubham Kumar

Hey, I am Shubham and i love Blogging, Coding and exploring new things and obviously sharing my experience with you.

3 Responses

  1. Erik says:

    Hi

    I couldn’t download this tutorial it says wait 20 seconds but nothing happens. Can you please send me files. I hope you see my email address.

    TY Erik

  2. Sandeep says:

    Nice Tut.
    Keep it up

Leave a Reply

Your email address will not be published. Required fields are marked *

shares