added token retrievel and upload

This commit is contained in:
2026-03-27 14:25:44 +01:00
parent e56c7fb7b5
commit b3ad26c580
4 changed files with 91 additions and 0 deletions

30
Get-GDriveToken.ps1 Normal file
View File

@@ -0,0 +1,30 @@
$client = Get-Content ".\client_secret.json" | ConvertFrom-Json
$clientId = $client.installed.client_id
$clientSecret = $client.installed.client_secret
$redirectUri = "http://localhost"
$scope = "https://www.googleapis.com/auth/drive.file"
$authUrl = "https://accounts.google.com/o/oauth2/v2/auth?client_id=$clientId&redirect_uri=$redirectUri&response_type=code&scope=$scope&access_type=offline"
Write-Host "Öffne folgende URL im Browser:"
Write-Host $authUrl
Start-Process $authUrl
$code = Read-Host "Code aus URL eingeben"
$body = @{
code = $code
client_id = $clientId
client_secret = $clientSecret
redirect_uri = $redirectUri
grant_type = "authorization_code"
}
$response = Invoke-RestMethod -Method Post -Uri "https://oauth2.googleapis.com/token" -Body $body
$response | ConvertTo-Json | Out-File "token.json"
Write-Host "Token gespeichert!"