Connect to PSB API with Powershell

I just got access to an API key and would like to pull some data from the PSB portal and compare with AD. Sadly I cannot figure out how to connect via Powershell.

Found this: https://community.f-secure.com/en/discussion/91901/conncet-to-api-via-powershell

where it seemed to be solved but the solutions isn't shown in the posts.

Can anyone point me in the right direction?

/Danny

Answers

  • jameschjamesch Posts: 152 Moderator

    Hi Danny

    The official help documents and Quick Start Guide can be found here. They contain the full documentation as well as examples of information requests.

  • PetriKuikkaPetriKuikka Posts: 205 F-Secure Employee

    Hi @DannyMalvang,

    did you get the problem sorted out? If not you can drop the calls you are trying to me in private message and I can check what is going wrong.

    Petri

  • h41ryb4wb46h41ryb4wb46 Posts: 1 New Member

    I use this method to obtain and save the token as a variable and then pass it to the authentication header for all subsequent request.


    $uri = "<API URL>/authentication/login"

    $auth = @{

      'X-API-Key' = "<api key>"

    }

    $body = @{

        'username' = '<username>'

        'password' = '<password>'

    }

    $token = (invoke-restmethod -Uri $tokenuri -Method Post -Headers $auth -Body $body).token

    $header = @{

      'X-API-Key' = "<api key>"

      'Authorization' = "Bearer $token"

    }

Sign In or Register to comment.