Jump to content
Sign in to follow this  
Denis_56

Авторизация в PowerShell на EXMO API

Recommended Posts

Авторизация в PowerShell на EXMO API

Добрый день, нужна помощь в написании скрипта на PowerShell.

Не получается получить данные пользователя, предполагаю проблема с кодировками.

Ошибка:  False 40007: Incorrect format parameter 'nonce'

Сам скрипт

$EXMURI = "https://api.exmo.me/v1/user_info"
$Time = (Get-Date).Ticks
$enc = [system.Text.Encoding]::UTF8

$secret = 'S-00000'
$key = 'K-11111'

$pay = @{
	nonce = "$Time"
}

$jsonencodedpl = ConvertTo-Json $pay
$byteencod = $enc.GetBytes($jsonencodedpl)

$hmacsha = New-Object System.Security.Cryptography.HMACSHA512
$hmacsha.key = $enc.GetBytes($secret)
$signature = $hmacsha.ComputeHash($enc.GetBytes($byteencod))

$signaturehex = $signature | ForEach-Object { $_.ToString("x2") }
$signaturehex = $signaturehex -join ""

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-type", "application/x-www-form-urlencoded")
$headers.Add("Key", $key)
$headers.Add("Sign", $signaturehex)

Invoke-RestMethod -Method Post -Uri $EXMURI -Headers $headers

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...