JayFF
Posts: 119
Joined: Fri Oct 03, 2014 1:03 am
Location: USA
Contact: Website

Inject Token In Rest API Request URL

Wed Jul 18, 2018 1:33 am

Hi All,

Do you have an example of how to inject the authorization key into the Request URL when pulling users information from the database using the new REST API? I am testing the new REST API by working with the test web site which is really impressive:
http://host_name/comGpsGate/api/v.1/test
I used the "Tokens" resource to retrieve an ApiKey and then used the "Authorize" button to validate the token. That all succeeds and when I click the Execute button in the "Try It Out" section of the Users:user section, it returns the users. The URL section of the "Try It Out" page shows this:
http://[host name redacted]/comGpsGate/api/v.1/applications/46/users?FromIndex=0&PageSize=1000
I've tried pasting that url into a web browser and I get "Unauthorized". I've tried a couple of different ways to inject the token but none of them have worked.

Thanks as always for any assistance.

Regards,
Jay
J. F. Florey

User avatar
reza_khamooshi
GpsGate
Posts: 9
Joined: Mon Mar 14, 2016 7:29 pm
Location: Sweden
Contact: Website

Re: Inject Token In Rest API Request URL

Wed Jul 18, 2018 2:51 pm

Hi Jay,

The API token should be sent in the HTTP Authorization request header, you cannot sent it in query string.

But if the API token is not provided, it falls back on session authentication. Meaning that if you login to one of your applications in your browser and open another tab in the same browser and paste the url:
http://[host name redacted]/comGpsGate/api/v.1/applications/46/users?FromIndex=0&PageSize=1000,
you will get a list of users without sending the authentication header.

Best regards,
Reza Khamoushi

JayFF
Posts: 119
Joined: Fri Oct 03, 2014 1:03 am
Location: USA
Contact: Website

Re: Inject Token In Rest API Request URL

Thu Jul 19, 2018 10:22 pm

Hi Reza,

Thank you very much. I implemented authorization in the request header and it works fine.

Regards,
Jay
J. F. Florey

Return to “GpsGate for Developers”