Logging example would be useful

Aperta
#1,560 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
php
Ambito
documentation

Direzione di ricerca

Inizia con lo stack di handler di GraphClientFactory, Middleware::log e la configurazione di GraphRequestAdapter mostrati nell’issue. Verifica perché l’esempio fornito per la creazione del client va in crash e documenta un modo pratico per registrare i dettagli delle richieste e delle risposte di Graph API. Il lavoro è completato quando un nuovo contribuente può seguire l’esempio correttamente e ispezionare i dati scambiati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

documentation type:question

I can't find any practical examples of how to apply logging to graph requests. When things don't work as expected it's really handy to be able to see what you are actually sending and receiving from the API.

I've tried the following but it crashes trying to create the client:

        $this->tokenRequestContext = new AuthorizationCodeContext(
            $this->config['tenant_id'],
            $this->config['app_id'],
            $this->config['client_secret_value'],
            'NOT_AUTHENTICATED', // Auth code dummy value
            $this->urlGenerator->generate('ms365_login_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
        );

        $tokenCache = new UserAccessTokenCache($this->tokenRequestContext); // Custom cache
        // Create the default handler stack
        $handlerStack = GraphClientFactory::getDefaultHandlerStack();

        // Add the log handler
        $handlerStack->push(Middleware::log(
            $this->logger,
            new \GuzzleHttp\MessageFormatter('{req_headers} - {req_body} - {res_headers} - {res_body}')
        ));

        $adapter = new GraphRequestAdapter(
            GraphPhpLeagueAuthenticationProvider::createWithAccessTokenProvider(
                GraphPhpLeagueAccessTokenProvider::createWithCache(
                    $tokenCache,
                    $this->tokenRequestContext,
                    self::AZURE_SCOPES
                )
            ),
            GraphClientFactory::createWithMiddleware($handlerStack)
        );

        $this->graphServiceClient = GraphServiceClient::createWithRequestAdapter($adapter);

Any help with this would be very handy.

Lingua principale
PHP
Stelle
669
Fork
149
Merge medio
1g 4h
PR unite (30g)
5

Preparare l'ambiente

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.

Altre issue di microsoftgraph/msgraph-sdk-php

Tutte le issue di microsoftgraph/msgraph-sdk-php

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.