How to compose HTML to get access token

Please see attached.

I have some idea of what they want me to do, but I am not clear on what the html looks like. I'm guessing a form.

Can someone show me what the HTML looks like?

Thanks,

Richard
xpo_token.pdf
Richard KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
The API is explained here https://www.xpo.com/solutions/transportation/ltl-help-center/api

What you need to do is construct a POST request to https://api.ltl.xpo.com/token
You will need to set the header of the request to include an Authorization: basic header with your security token

Authorization: Basic <token>

Where token is made up of the base64 encoded result of your consumer key and consumer secret concatenated to each other.

You then send as the body of the request the url encoded grant_type, username and password values
grant_type=password&username=demo&password=password

Open in new window


This would typically be done from a server side process (PHP CUrl for example).

If all checks out you should get back a JSON response which contains a property access_token the value of which must be used in all other API calls - it is a temporary access token - if it expires you need to repeat the above process to refresh it.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
As Julian mentioned, likely what's tripping you up is you're thinking about this in terms of client side HTML, rather than a server site POST request.

What you'll do is...

1) Craft a POST request to your API Endpoint.

2) Get back a token.

3) Craft additional POST requests using the token, to acquire additional information.
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
I tried a cut at it, as I expected, it failed, I got this:

Fatal error: Call to a member function xpath() on boolean in /home/lakoshva/public_html/get_XPO_access.php on line 23

I will email you the code as it has password, etc. in it. The function xpath DID work in a prior version, NOT being defined in the php program referencing it. How, I have no clue, I understand the error.

Richard
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
David Favor,

Thank you. I was referring to Julian about the email of the code.

Thanks.

I can email to you too, I don't want to post it on the open EE exchange, I will need your email.

Richard
Julian HansenCommented:
Had a look at the code - posting findings here so other experts can weigh in.

The code had a few glitches which when fixed allowed a connection but returned an invalid client.

Next step is to look at the credentials.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.