Last active
February 16, 2016 21:32
-
-
Save jt-nti/5ee522b2d61a4ff1ddb1 to your computer and use it in GitHub Desktop.
Attempting to use keybase.io API with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Keybase experiment. | |
.DESCRIPTION | |
Beginnings of a PowerShell script to post a Keybase signature announcement. Still not finished but the following commands do work, which is nice. | |
.PARAMETER SignedJsonPath | |
A file containing the signed JSON Object, e.g. created using the following command, | |
gpg2 -u "..." -a --sign keybase-json.txt | |
.PARAMETER Session | |
.PARAMETER CsrfToken | |
.PARAMETER SigningKid | |
.PARAMETER Uid | |
.EXAMPLE | |
Keybase-IO -SignedJson .\keybase-json.txt.asc | |
.LINK | |
tbc | |
#> | |
param( | |
[Parameter(Mandatory=$true)][string]$SignedJsonPath, | |
[Parameter(Mandatory=$true)][string]$Session, | |
[Parameter(Mandatory=$true)][string]$CsrfToken, | |
[Parameter(Mandatory=$true)][string]$SigningKid, | |
[Parameter(Mandatory=$true)][string]$Uid | |
) | |
$url = "https://keybase.io/_/api/1.0/follow.json" | |
$in = Get-Content -Path $SignedJsonPath -Raw | |
Write-Host "Posting signature:" | |
$in.substring(0,200) | |
$sig = $in -replace '\r','' | |
$headers = @{ | |
"X-CSRF-Token" = $CsrfToken | |
} | |
$body = @{ | |
sig = $sig | |
type = "track" | |
session = $Session | |
plain_out = "1" | |
signing_kid = $SigningKid | |
uid = $Uid | |
} | |
Invoke-RestMethod -Method Post -Uri $url -Headers $headers -Body $body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment