Closed MilesHart closed 2 years ago
Hey @MilesHart, Same problem, have you found a solution ?
I've just ran through this on a new app, its working for me. Can you check your files over these:
Routes:
Route::redirect('/', 'login');
Route::group(['middleware' => ['web', 'guest'], 'namespace' => 'App\Http\Controllers\Auth'], function(){
Route::get('login', 'AuthController@login')->name('login');
Route::get('connect', 'AuthController@connect')->name('connect');
});
Route::group(['middleware' => ['web', 'MsGraphAuthenticated'], 'prefix' => 'app', 'namespace' => 'App\Http\Controllers'], function(){
Route::get('/', 'PagesController@app')->name('app');
Route::get('logout', 'Auth\AuthController@logout')->name('logout');
});
Pages controller:
<?php
namespace App\Http\Controllers;
use Dcblogdev\MsGraph\Facades\MsGraph;
class PagesController extends Controller
{
public function app()
{
dd(MsGraph::get('me'));
}
}
Auth controller:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Dcblogdev\MsGraph\Facades\MsGraph;
class AuthController extends Controller
{
public function login()
{
return view('auth.login');
}
public function connect()
{
return MsGraph::connect();
}
public function logout()
{
return MsGraph::disconnect('/');
}
}
Login blade view:
<div class="bg-gray-200 dark:bg-gray-700 dark:text-white min-h-screen py-32 px-10">
<div class="text-center mb-10 md:w-3/4 lg:w-1/2 mx-auto">
<div class="text-5xl tracking-tight leading-10 font-extrabold text-gray-900 dark:text-white">
{{ config('app.name') }}
</div>
</div>
<div class="bg-white dark:bg-gray-600 p-10 rounded-lg shadow-lg w-full lg:w-1/3 mx-auto">
<div class="bg-yellow-100 border-t-4 border-yellow-500 rounded-b text-yellow-900 px-4 py-3 shadow-md" role="alert">
<div class="flex">
<div class="py-1"><svg class="fill-current h-6 w-6 text-yellow-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z"/></svg></div>
<div>
<p class="font-bold">We use Microsoft 365 for accessing your account.</p>
<p class="text-sm">Click the button below to get started.</p>
</div>
</div>
</div>
<p><a class="mt-5 w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" href="{{ route('connect') }}">Login with your Microsoft Account</a></p>
</div>
</div>
What version of Laravel do you use ? In my case I work with Laravel 9.23,
I try to use this package since yesterday and I can't work it.
/msgraph/oauth
or /connect
?
# https://dcblog.dev/docs/laravel-microsoft-graph
MSGRAPH_OAUTH_URL = https://domain.com/msgraph/oauth
MSGRAPH_LANDING_URL = https://domain.com/msgraph
# https://dcblog.dev/docs/laravel-microsoft-graph/msgraph/login-with-msgraph
MSGRAPH_OAUTH_URL = https://project.com/connect
MSGRAPH_LANDING_URL = https://project.com/app
https://dcblog.dev/docs/laravel-microsoft-graph/introduction/application-register
In the first case /msgraph/oauth
, I have error 404
like @MilesHart
In the otherwise with /connect
, I have a blank page with error
<html><head></head><body>error:invalid_client</body></html>
Thanks for your back @dcblogdev 👍
I'm using the latest version just installed this morning on Laravel 9
ah I used to use msgraph/oauth but I then prefer to use connect you can use either as long as your routes match the env endpoints.
In my env I set the paths as:
MSGRAPH_OAUTH_URL=https://microsoft365demo.localhost/connect MSGRAPH_LANDING_URL=https://microsoft365demo.localhost/app
I'll do a video walk through tonight to show my steps
ah I used to use msgraph/oauth but I then prefer to use connect you can use either as long as your routes match the env endpoints.
Like me, I prefere use /connect
is too clear.
However Sign-on logs of AD are success
but /connect
retrun that
Is my Laravel configuration or AD configuration which are bad, I don't know ?
I'll do a video walk through tonight to show my steps
It a good idea, but the documentation is also clear and good, juste some correction or details to improve it. Also you can put with which versions of Laraval the package is tested or compatible.
I think that is your client id from AD doesn't appear to be valid.
okay recorded a video of the progress https://www.youtube.com/watch?v=fvgd2RYc3G0
I've followed the instruction twice now, and unable to resolve this issue.
It goes to MS to confirm login/password/MFA then returns to
https://ccpoc.dd/msgraph/oauth?code=0.AQkArh-U4PDsz0u3wnZaCKL4Ky3.........
and rendering a 404 error?
Very simple single tenant...
Any help would be appreciated.