none
Use Invoke-RestMethod with Access Token RRS feed

  • Question

  • Hi, I am not new to PowerShell, but I am new to using this cmdlet.  I need to use the Invoke-RestMethod to make a call to a webservice api using OAuth.  I need to get an access token from the webservice and then use the obtained token to make an api call to the webservice's API.  I have seen numerous posts and scripts that show how to make a call to a webservice api, but they never show how to get an access token and assume that you already have one.

    I would appreciate any help anyone could provide!

    Thanks in advance!


    Tim

    Thursday, September 29, 2016 4:01 AM

Answers

All replies

  • You need to review the web service documentation on how t obtain a token using OAuth.

    Here are some examples of how to get tokens from some common API services.

    https://marckean.com/2015/09/21/use-powershell-to-make-rest-api-calls-using-json-oauth/


    \_(ツ)_/

    • Marked as answer by TimStspry Thursday, September 29, 2016 3:38 PM
    Thursday, September 29, 2016 4:46 AM
  • Thank you for your reply and the link.  I forgot to mention that my PowerShell script will be run completely without user interaction.  There won't be any forms to fill out, or registering of an app.  I get all of the information needed from the webservice itself.  If you know of any examples of how to do this, I would greatly appreciate it!

    Thanks in advance!


    Tim

    Thursday, September 29, 2016 3:26 PM
  • I know of know web APIs that allow dynamic registration.  If you know of one then use the documentation from that API or site to learn how to do it.


    \_(ツ)_/

    Thursday, September 29, 2016 3:36 PM