Coder Social home page Coder Social logo

Comments (7)

dcblogdev avatar dcblogdev commented on September 3, 2024

thanks for reporting this, looks to be a problem with the API structure, not sure if there's been changes from Microsoft.

It seems that it no longer accepts a resource type when authenticating as a tenant, I've replicated this locally and working on testing it deeper before issuing a release.

Thank you for your time and for maintaining this repository. I am a big fan of your work and I appreciate all the effort you have put into it.

thank you, its great to hear its been useful to you.

from laravel-microsoft-graph.

Kristianmarku avatar Kristianmarku commented on September 3, 2024

thanks for reporting this, looks to be a problem with the API structure, not sure if there's been changes from Microsoft.

It seems that it no longer accepts a resource type when authenticating as a tenant, I've replicated this locally and working on testing it deeper before issuing a release.

Thank you for your time and for maintaining this repository. I am a big fan of your work and I appreciate all the effort you have put into it.

thank you, its great to hear its been useful to you.

I truly hope that you can find a solution to fix this issue soon. As I mentioned, I need this package for a project and it would be a huge setback for me if I can't use it. I will definitely keep an eye out for updates and hope that you can resolve this as soon as possible. Thank you again for all your hard work and for providing such a valuable resource.

from laravel-microsoft-graph.

dcblogdev avatar dcblogdev commented on September 3, 2024

I've just pushed up a new release now.

from laravel-microsoft-graph.

Kristianmarku avatar Kristianmarku commented on September 3, 2024

I've updated the repository in my project, and now when this function is executed:

public function connect()
    {
       return MsGraphAdmin::connect();
    }

The website just returns json data!? Though I've set up routes for when user is authenticated via Microsoft, to return to a blade view which fetches some user data.

image

Is the issue on my project side or If I could get some help...?

from laravel-microsoft-graph.

dcblogdev avatar dcblogdev commented on September 3, 2024

with the new change added, connect doesn't need to be loaded directly after you've initially connected. Once you have a token a token would be requested when needed.

take this example:

Route::group(['middleware' => ['web', 'MsGraphAdminAuthenticated']], function(){
    Route::get('/', function(){
        //fetch all users
        return MsGraphAdmin::get('users');
    });
});

Route::get('connect', function(){
    return MsGraphAdmin::connect();
});

I'm loading users on a / route internally called connect when needed. If I manually go to the route then I see the same output as you see above.

from laravel-microsoft-graph.

Kristianmarku avatar Kristianmarku commented on September 3, 2024

When the user clicks on the "Login" button, it redirects him to the route "connect", which before authenticated the user,
and then the view blade was returned, now It just shows json data in the web. So how do I authenticate the user first, then redirect him to my view?

When I use MsGraph, instead of Admin, then when MsGraph::connect is returned, it sends the me to the Microsoft Login Form, and select an account then it authenticates me and redirects me to my view blade with the user data. But with MsGraphAdmin, instead of sending to Microsoft Login Form, it just prints the json data, the image that I uploaded above shows it.

Web routes:

Route::get('/', function () {
    return view('auth.login');
})->name('login');


Route::group(['middleware' => ['web', 'auth']], function(){
    Route::post('meeting', [AuthController::class, 'storeMeeting'])->name('meeting.store');
});
    
Route::group(['middleware' => ['web', 'guest'], 'namespace' => 'App\Http\Controllers'], function(){
    Route::get('msgraph', 'AuthController@index')->name('index');
    Route::get('msgraph/oauth', 'AuthController@connect')->name('connect');
});

AuthController:

<?php

namespace App\Http\Controllers;

use Dcblogdev\MsGraph\Facades\MsGraphAdmin;
use Illuminate\Http\Request;

class AuthController extends Controller
{
    public function index()
    {
        if (! is_string(MsGraphAdmin::getAccessToken())) {
            return redirect(env('MSGRAPH_OAUTH_URL'));
        } else {
            // Display Details
            $user = MsGraphAdmin::get('me');
            $contacts = MsGraphAdmin::get('me/contacts');
            $events = MsGraphAdmin::get('me/events');
            $teams = MsGraphAdmin::get('me/joinedTeams');

            $meetings = [];
            foreach ($teams['value'] as $team) {
                $teamMeetings = MsGraphAdmin::get("teams/{$team['id']}/events");
                $meetings = array_merge($meetings, $teamMeetings['value']);
            }

            return view('welcome', compact('user', 'contacts', 'events', 'meetings'));
        }
    }

    public function connect()
    {
        return MsGraphAdmin::connect();
    }

    public function logout()
    {
        return MsGraphAdmin::disconnect('/');
    }


    public function storeMeeting(Request $request)
    {
        if (! MsGraphAdmin::isConnected()) {
            return redirect('msgraph/oauth');
        }

        $subject = $request->input('subject');
        $start_time = $request->input('start_time');
        $end_time = $request->input('end_time');

        $data = [
            'subject' => $subject,
            'start' => [
                'dateTime' => $start_time,
                'timeZone' => 'UTC',
            ],
            'end' => [
                'dateTime' => $end_time,
                'timeZone' => 'UTC',
            ],
        ];

        $response = MsGraphAdmin::post('/me/onlineMeetings', $data);

        return redirect()->back();
    }
}

from laravel-microsoft-graph.

dcblogdev avatar dcblogdev commented on September 3, 2024

I understand, I'm working on a way this can be used as both in the background and via user interaction.

stretch that I've pushed a new release where connect will redirect by default. To stop this pass false as a param and only the token would be returned.

I do want to clean up the internal code its getting pretty messy.

from laravel-microsoft-graph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.