added token retrievel and upload
This commit is contained in:
30
Get-GDriveToken.ps1
Normal file
30
Get-GDriveToken.ps1
Normal 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!"
|
||||
Reference in New Issue
Block a user