Skip to content

Commit

Permalink
added token retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichWeinmann committed Mar 5, 2024
1 parent e33df64 commit 48b2147
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion MiniGraph/MiniGraph.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'MiniGraph.psm1'

# Version number of this module.
ModuleVersion = '1.3.13'
ModuleVersion = '1.3.16'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -69,6 +69,7 @@ FunctionsToExport = @(
'Connect-GraphCredential'
'Connect-GraphDeviceCode'
'Connect-GraphToken'
'Get-GraphToken'
'Invoke-GraphRequest'
'Invoke-GraphRequestBatch'
'Set-GraphEndpoint'
Expand Down
7 changes: 4 additions & 3 deletions MiniGraph/functions/Connect-GraphBrowser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
The path to the browser to use for the authentication flow.
Provide the full path to the executable.
The browser must accept the url to open as its only parameter.
Defaults to Edge.
Defaults to your default browser.
.PARAMETER NoReconnect
Disables automatic reconnection.
Expand Down Expand Up @@ -74,7 +74,7 @@
$Resource = 'https://graph.microsoft.com/',

[string]
$Browser = $script:browserPath,
$Browser,

[switch]
$NoReconnect
Expand Down Expand Up @@ -124,7 +124,8 @@
catch { Invoke-TerminatingException -Cmdlet $PSCmdlet -Message "Failed to create local http listener on port $LocalPort. Use -LocalPort to select a different port. $_" -Category OpenError }

# Execute in default browser
& $Browser $uriFinal
if ($Browser) { & $Browser $uriFinal }
else { Start-Process $uriFinal }

# Get Result
$task = $http.GetContextAsync()
Expand Down
28 changes: 28 additions & 0 deletions MiniGraph/functions/Get-GraphToken.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function Get-GraphToken {
<#
.SYNOPSIS
Retrieve the currently used graph token.
.DESCRIPTION
Retrieve the currently used graph token.
Use one of the Connect-Graph* commands to first establish a connection.
The token retrieved is a static copy of the current token - it will not be automatically refreshed once expired.
.EXAMPLE
PS C:\> Get-GraphToken
Retrieve the currently used graph token.
#>
[CmdletBinding()]
param (

)
process {
[PSCustomObject]@{
Token = $script:token
Created = $script:lastConnect.When
HasRefresh = $script:lastConnect.Refresh -as [bool]
Endpoint = $script:baseEndpoint
}
}
}
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.3.16 (2024-03-05)

+ New: Get-GraphToken - retrieve the currently used token
+ Upd: Connect-GraphBrowser - opens logon screen in the default browser by default
+ Fix: Invoke-GraphRequestBatch - retries stop failing

## 1.3.13 (2023-12-03)

+ Upd: Invoke-GraphRequestBatch - simplified requests specification
Expand Down

0 comments on commit 48b2147

Please sign in to comment.