Page 1 of 1

Unable to get access code.

Posted: Wed Jan 15, 2020 5:33 pm
by gsabatino
Hi there.

I am new to APIs... so I apologize in advance if this is elementary...

I'm using PowerShell to just grab the list of user accounts. Just some pieces of info. I need to do this programmatically instead of logging in every few days to get the list.

If I run the command in the browser (substituted with the correct values), it works just fine, however if I do it via command in PS, it doesn't return anything valuable:

Code: Select all

Invoke-WebRequest "$clientid&response_type=code&action=Login&username=$APIUSERNAME&password=$APIPassword"
I am returned the following:

Code: Select all

StatusCode        : 200
StatusDescription : OK
Content           : <!DOCTYPE html>
                    <html lang="en-US">
                    <!--Optimizely Script -->
                    <!--<script src=""></script>-->
                    <!-- Google Analytics-->
                     <!--<script async src='https:/...
RawContent        : HTTP/1.1 200 OK
                    Transfer-Encoding: chunked
                    Connection: keep-alive
                    Keep-Alive: timeout=20
                    Vary: Accept-Encoding,Accept-Encoding,Accept-Encoding,Cookie
                    Link: <>; re...
Forms             : {mktoForm_2674, mktoForm_3061}
Headers           : {[Transfer-Encoding, chunked], [Connection, keep-alive], [Keep-Alive, timeout=20], [Vary, Accept-Encoding,Accept-Encoding,Accept-Encoding,Cookie]...}
Images            : {@{innerHTML=; innerText=; outerHTML=<IMG style="MAX-WIDTH: 185px; MARGIN: 0px auto" src="">; outerText=; 
                    tagName=IMG; style=MAX-WIDTH: 185px; MARGIN: 0px auto; src=}, @{innerHTML=; innerText=; outerHTML=<IMG 
                    src="/wp-content/uploads/2018/10/Product__Applicant-TrackingCRM.png">; outerText=; tagName=IMG; src=/wp-content/uploads/2018/10/Product__Applicant-TrackingCRM.png}, @{innerHTML=; innerText=; 
                    outerHTML=<IMG src="/wp-content/uploads/2018/10/Product__Onboarding.png">; outerText=; tagName=IMG; src=/wp-content/uploads/2018/10/Product__Onboarding.png}, @{innerHTML=; innerText=; 
                    outerHTML=<IMG src="">; outerText=; tagName=IMG; 
InputFields       : {}
Links             : {@{innerHTML=Chrome; innerText=Chrome; outerHTML=<A href="">Chrome</A>; outerText=Chrome; tagName=A; 
                    href=}, @{innerHTML=Contact; innerText=Contact; outerHTML=<A class=btn href="/contact/">Contact</A>; outerText=Contact; tagName=A; class=btn; 
                    href=/contact/}, @{innerHTML=; innerText=; outerHTML=<A class=navbar-brand href=""></A>; outerText=; tagName=A; class=navbar-brand; href=}, 
                    @{innerHTML=Products; innerText=Products; outerHTML=<A href="#">Products</A>; outerText=Products; tagName=A; href=#}...}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 167156
When using a browser, I'm prompted for an accept screen. If I do, I get redirected to another page, but the URL shows the code=, which I assume is followed by the authorization code, which is then used to obtain the OAUTH key.

Can anyone point me in the right direction?