mirror of
https://github.com/dafthack/GraphRunner
synced 2026-06-08 13:44:02 +00:00
Added check for global token
This commit is contained in:
+22
-17
@@ -1475,25 +1475,29 @@ function Get-TeamsApps{
|
||||
$Tokens
|
||||
)
|
||||
if(!$Tokens){
|
||||
# Login
|
||||
Write-Host -ForegroundColor yellow "[*] First, you need to login."
|
||||
Write-Host -ForegroundColor yellow "[*] If you already have tokens you can use the -Tokens parameter to pass them to this function."
|
||||
while($auth -notlike "Yes"){
|
||||
Write-Host -ForegroundColor cyan "[*] Do you want to authenticate now (yes/no)?"
|
||||
$answer = Read-Host
|
||||
$answer = $answer.ToLower()
|
||||
if ($answer -eq "yes" -or $answer -eq "y") {
|
||||
Write-Host -ForegroundColor yellow "[*] Running Get-GraphTokens now..."
|
||||
$tokens = Get-GraphTokens -ExternalCall
|
||||
$auth = "Yes"
|
||||
} elseif ($answer -eq "no" -or $answer -eq "n") {
|
||||
Write-Host -ForegroundColor Yellow "[*] Quitting..."
|
||||
return
|
||||
} else {
|
||||
Write-Host -ForegroundColor red "Invalid input. Please enter Yes or No."
|
||||
if ($global:tokens){
|
||||
$tokens = $global:tokens
|
||||
} else {
|
||||
# Login
|
||||
Write-Host -ForegroundColor yellow "[*] First, you need to login."
|
||||
Write-Host -ForegroundColor yellow "[*] If you already have tokens you can use the -Tokens parameter to pass them to this function."
|
||||
while($auth -notlike "Yes"){
|
||||
Write-Host -ForegroundColor cyan "[*] Do you want to authenticate now (yes/no)?"
|
||||
$answer = Read-Host
|
||||
$answer = $answer.ToLower()
|
||||
if ($answer -eq "yes" -or $answer -eq "y") {
|
||||
Write-Host -ForegroundColor yellow "[*] Running Get-GraphTokens now..."
|
||||
$tokens = Get-GraphTokens -ExternalCall
|
||||
$auth = "Yes"
|
||||
} elseif ($answer -eq "no" -or $answer -eq "n") {
|
||||
Write-Host -ForegroundColor Yellow "[*] Quitting..."
|
||||
return
|
||||
} else {
|
||||
Write-Host -ForegroundColor red "Invalid input. Please enter Yes or No."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$access_token = $tokens.access_token
|
||||
$headers = @{
|
||||
Authorization = "Bearer $access_token"
|
||||
@@ -1526,6 +1530,7 @@ function Get-TeamsApps{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Get-TeamsChat{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
Reference in New Issue
Block a user