Solved Help with API setup

Discussion in 'AutoWeb' started by tomaski, Dec 6, 2017.

  1. tomaski

    tomaski Administrator

    Joined:
    Feb 4, 2015
    Messages:
    3
    Likes Received:
    1
    Hi guys,

    so I need some assistance setting up API.
    Hardcoding certain things would not be a problem, but since I'd like to make it exportable...

    So... the API I am setting up is for a car fleet tracking.
    base URL is
    Code (Text):
    https://secure.geotrack.com/api
    followed by your (mine) applicaton name, like
    Code (Text):
    https://secure.geotrack.com/api/appname
    then all the endpoints are added to the URL
    so for example endpoint
    Code (Text):
    json/util/login
    will make the URL look like
    Code (Text):
    https://secure.geotrack.com/api/appname/json/util/login
    and then, at the very end, access token is appended
    Code (Text):
    ?userkey=####################
    so the complete request will look like
    Code (Text):
    https://secure.geotrack.com/api/appname/json/util/login?userkey=############
    any ideas how to do the initial setup, to ask user for both the app name and userkey?
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    5,269
    Likes Received:
    482
    Hi! :)
    • Set the base URL to https://secure.geotrack.com/api/{appname}/
    • Create a default parameter with the appname key (with the type Path) and tell users to setup a value for it in the Web Service Settings section since it'll be a constant for all the invocations
    • If json/util/ is part of all API URLs make that part of the base URL as well to save work for all the endpoints
    • Create another default parameter with the userkey key (with the type Query) and tell users to setup a value for it in the Web Service Settings section since it'll be a constant for all the invocations
    I think that should do it :) Let me know if this helps.
     
  3. tomaski

    tomaski Administrator

    Joined:
    Feb 4, 2015
    Messages:
    3
    Likes Received:
    1
    Hi Joao,

    yeah that works :D
    thanks for your swift response :)
     
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    5,269
    Likes Received:
    482
    No problem! :) Glad it all worked!
     
  5. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    5,269
    Likes Received:
    482
    Oh, I forgot something!
    The userkey should not be configured as an API input, sorry! You should use the "Secret Key" authentication method and enable the "Safeguard Private Info" option. Users will be prompted to input their keys when appropriate :) Sorry for the confusion!
     
  6. tomaski

    tomaski Administrator

    Joined:
    Feb 4, 2015
    Messages:
    3
    Likes Received:
    1
    Hi Joao,

    after I moved the userkey to the secret key section, it is no longer working.
    What I did:
    set authentication to use secret key
    set secret key and secret key parameter ("userkey" and/or blank)

    then in API actions I edited the action:
    path: json/util/login?userkey={secretkeyautoweb}

    and I'm getting "not logged in" error
     
  7. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    5,269
    Likes Received:
    482
    You should use the key in the URL at all :) It'll be added for you. Make sure to set Secret Key to blank and Secret Key Parameter to userkey.

    That should make it ask you for the key :)

    Hope this helps!
     
: help, setup

Share This Page