microsoftgraph / microsoftgraph/msgraph-sdk-php

How to Retrieve MS Graph User email and pass extra parameters to callback redirect URL? (Auth, Login with Microsoft button)

Aperta
#1,558 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@timayabi2020 ci sta già lavorando.

Dal 8/8/2024.

type:question
Lingua principale
PHP
Stelle
669
Fork
150
Merge medio
15h 21m
PR unite (30g)
3

Descrizione

Sorry, I am very dumb, I've searched around, and couldn't find how to do the most basic stuff with the latest v2 of SDK.

I need to add the "Login with Microsoft" button to my app, like I have with Google.

I have created an App and have all the tenant IDs and redirect URL.

Two methods have to be implemented:

  1. Generate a redirect URL from my app to Microsoft login/consent page
  2. Callback function where I retrieve the user's email and handle authentication in the app, not related to Microsoft, I don't need to store any access keys, etc.

I need something like:

public function redirectToMicrosoft(Request $request) {
   $tenant = ...
   $clientId = ...
   $clientSecret = ...
   $callbackUrl = ...
   $scopes = ['User.Read']

   $extra_params = ['stuff' => 'something']

   // What do I need here to generate the URL from my tenant and other secrets?
   $url = $microsoft->getAuthURL($tenant etc, $extra_params)

   redirect($url)
public function handleMicrosoftCallback(Request $request) {

   // What do I need here to retrieve the user's name/email and extra_params?
   $ms_user = $microsoft->user();
   $extra_params = $microsoft->getState();
   $name = $ms_user->getName();
   $email = $ms_user->getEmail();

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.