PSMSGraph icon indicating copy to clipboard operation
PSMSGraph copied to clipboard

BaseURL in Get-GraphOauthAuthorizationCode should default to \authorize?

Open hanpq opened this issue 6 years ago • 1 comments

I think the default of BaseUrl should default to end with "?" so that it is possible to provide a baseurl with custom added parameters. For instance i want to utilize the optional parameter "prompt=select_account" to force the user to get a prompt asking the user to select an account. At the moment the "?" is added on the line 69;

$Url = "{0}?response_type=code&redirect_uri={1}&client_id={2}" -f @(

So if I would provide the custom parameter in the baseurl it would be: $BaseURL = ....\authorize?prompt=select_account& which would result in the following concatinated string: \authorize?prompt=select_account&?response_type=code&....

If the "?" is appended to the default baseurl and removed from the string-formater it would be possible to override the first parameter.

So if I then provide the same BaseUrl the resulting URL would instead be correct; $BaseURL = ....\authorize?prompt=select_account& \authorize?prompt=select_account&response_type=code&....

Thanks!

hanpq avatar Apr 29 '19 12:04 hanpq

That would be better handled by adding new parameters. the base URL is traditionally everything before a ? and queries are appended after. So adding something like a -Query dictionary parameter and appending those as a generated part of the query string would be the best way to solve this. We have to control the query string in the function because we have to pass some required fields and values. so we cannot expose a raw query string to the end user.

markekraus avatar May 04 '19 21:05 markekraus