Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JustinGrote opened this issue Mar 9, 2020 · 6 comments · Fixed by #245
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@JustinGrote
Copy link

JustinGrote commented Mar 9, 2020

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.

@ghost ghost added the ToTriage label Mar 9, 2020
@darrelmiller darrelmiller added this to the 1.0 GA milestone Mar 11, 2020
@darrelmiller darrelmiller added enhancement New feature or request and removed ToTriage labels Mar 11, 2020
@darrelmiller
Copy link
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 @peombwa

@BHoggs BHoggs mentioned this issue Mar 15, 2020
@jmiller76
Copy link

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

Do what you need?

@JustinGrote
Copy link
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)
}

@BHoggs
Copy link
Contributor

BHoggs commented Apr 15, 2020

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

@JustinGrote JustinGrote reopened this Apr 15, 2020
@JustinGrote
Copy link
Author

@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.

@darrelmiller
Copy link
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
Labels
enhancement New feature or request
Projects
None yet
5 participants