Skip to content

[FeatureRequest] New Command Get-GraphClient that returns the httpclient used by the module. #127

Closed

Description

The current Autorest-based module has several limitations. Please make it easy to work around those limitations by exposing the httpclient used by the module so that we can invoke additional custom queries.

Alternatively, Add a Invoke-Graph -URI that runs a request using the existing Httpclient and returns the raw output.

This way the graph API token doesn't have to be directly exposed (sure you can still fetch it from the cookies property of the httpclient, but it's not stored securely in memory cross-platform anyways)

Use case: I want to download files with /content, there's no option to do that, and if I try to modify an existing client with an HTTPRequesthandler, the downloaded file is not in json format so the command still fails.

Activity

  1. added this to the 1.0 GA milestone on Mar 11, 2020
  2. darrelmiller commented on Mar 11, 2020

    @darrelmiller
    Contributor

    Having some kind of Invoke-GraphRequest seems like a good idea. It also is a good workaround for us being able to get at non-JSON responses. /cc Peter Ombwa (@peombwa)

  3. jmiller76 commented on Apr 1, 2020

    @jmiller76

    Justin Grote (@JustinGrote) does
    $Client = [Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers]::GetGraphHttpClient((Get-MgContext))

    Do what you need?

  4. JustinGrote commented on Apr 1, 2020

    @JustinGrote
    Author

    Yes it does! Thanks for hunting down that extension method for me, I hadn't upgraded to 0.2.0 yet.

    I put this function in my profile for convenience:

    function Get-GraphClient ($context = (Get-MGContext)) {
      [Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers]::GetGraphHttpClient($context)
    }
  5. BHoggs commented on Apr 15, 2020

    @BHoggs
    Contributor

    Justin Grote (@JustinGrote) I see you closed this issue - despite finding a workaround using the extension method, as per Darrel (@darrelmiller)'s comment I still feel the module would benefit from a Invoke-GraphRequest type of Cmdlet? Should this stay open for that purpose?

  6. JustinGrote commented on Apr 15, 2020

    @JustinGrote
    Author

    Brett Hoggins (@BHoggs) I'd be fine with it if it's within the scope of the team, to use, so we can note that the workaround is sufficient but having it as a cmdlet would be better.

  7. darrelmiller commented on May 7, 2020

    @darrelmiller
    Contributor

    finsharp We should create a wrapper cmdlet called Invoke-GraphRequest that allows arbitrary calls to the Graph with the token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions