1

Get login token with an HTTP call?

(27/09/2019 16:18:00 отредактировано adriangandelman)

Тема: Get login token with an HTTP call?

Is there still a way to get the login token with an HTTP call for Wialon Hosting API? Instead of having to manually browse and type username and password.

2

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

No

3

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

adriangandelman пишет:

Is there still a way to get the login token with an HTTP call for Wialon Hosting API? Instead of having to manually browse and type username and password.

If you logined as top user you can try to create new tokens for subusers with method token/update

4

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

muev пишет:
adriangandelman пишет:

Is there still a way to get the login token with an HTTP call for Wialon Hosting API? Instead of having to manually browse and type username and password.

If you logined as top user you can try to create new tokens for subusers with method token/update

How do you build this type of request?

Also, I don't understand what should I type in the following parameters:
- h: unique token name
- app: application name
- fl: access flags
- items: list of item ids with token granted access
- p: custom parameters, value must be object or an array of objects

Quoting the whole list of parameters:

{
    "h":<text>,        /* unique token name, 72 symbols */
    "app":<text>,        /* application name */
    "at":<uint>,        /* token activation time, UNIX-time */
    "ct":<uint>,        /* token creation time, UNIX-time */
    "dur":<uint>,        /* token duration after activation, секунды */
    "fl":<uint>,        /* access flags */
    "items":[<long>],    /* list of item ids with token granted access */
    "p":<text>        /* custom parameters, value must be object or an array of objects */
}

5

Get login token with an HTTP call?

(17/02/2020 10:09:25 отредактировано hhamedk)

Re: Get login token with an HTTP call?

adriangandelman, as muev explained previously, this method should be used for creating (or better to say managing) other sub-user's (or even same user) Tokens. So, you need to have a valid Token before using this method and more likely you have obtained mentioned Token from the way you called it "manually browse and type username and password".
Now, Considering you have a valid top-user Token. these are the parameters you need to pass (you have copied response instead of request parameters):

{"callMode":<text>,
"userId":<text>,
"h":<text>,
"app":<text>,
"at":<uint>,
"dur":<uint>,
"fl":<uint>,
"p":<text>,
"items":[<long>],
"deleteAll":<bool>|<text>}

"callMode":  based on what you explained you should set it to "create"

"userId":  Id of user you want to creat the Token for, one of your sub-users or the same user that you have a valid Token for.

"h":  The token you want to manage (update or delete). In your case as you are going to create new Token you don't need to pass this parameter.

"app":  This parameter is like a description that in future will help you to understand for which application you have created the Token, Consider you have different applications named X, Y and Z, with this parameter you can find later that the Token in created for which.

"at":  Activation time of Token, you may create the Token now but want to activate it 6 hour later, means after 6 hours this Token is usable not now.

"dur":  Duration of time that the Token will be activate after activation time.

"fl":  It's clear enough.

"p":  Array you custom JSON parameters you may wish to add to the Token and it's optional.

"items":   Optional

"deleteAll":  Not used in Create call mode.

6

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

Hello team,
I am having some problems with the token/update method, I already have a valid token previously and I want to perform the refresh function.

For this implement the following order in Postman:

https://hst-api.wialon.com/wialon/ajax.html?svc=token/update&params={"callMode" : "update", "app":"appName", "at": "0",  "p":"{}","dur":"10000","fl":"512","h":"validToken" }

As a result I receive the following:
{
     "error": 7,
     "reason": "OPERATION_NOT_ALLOWED: for 'update' operation you should be authorized"
}

What can be caused this?

Thank you very much in advance.

7

Get login token with an HTTP call?

(28/05/2020 09:14:11 отредактировано muev)

Re: Get login token with an HTTP call?

ft.lussich пишет:

Hello team,
I am having some problems with the token/update method, I already have a valid token previously and I want to perform the refresh function.

For this implement the following order in Postman:

https://hst-api.wialon.com/wialon/ajax.html?svc=token/update&params={"callMode" : "update", "app":"appName", "at": "0",  "p":"{}","dur":"10000","fl":"512","h":"validToken" }

As a result I receive the following:
{
     "error": 7,
     "reason": "OPERATION_NOT_ALLOWED: for 'update' operation you should be authorized"
}

What can be caused this?

Thank you very much in advance.

Good afternoon!

You make this request as not authorized user without session ID (sid parameter in the request) which you have to receive in login request in "eid" field at first. Here an example of login request: token/login

8

Get login token with an HTTP call?

(28/05/2020 15:50:17 отредактировано ft.lussich)

Re: Get login token with an HTTP call?

Hello muev, thanks for your answer, add the parameter that suggests to me anyway I keep having the same error:

https://hst-api.wialon.com/wialon/ajax. … mp;params=
{
    "callMode" : "update",
    "userId" :"022968d542574d971f042fc00 ...",
    "app":"gurtam",
    "at": "0", 
    "p":"{}",
    "dur":"10000",
    "fl":"512",
    "h":"7c781e3218f2d523c9c9a08e3812253c8CB575C4BD7415DF65BCB ..."
}


I find it strange that in the documentation it says that the parameter is optional

https://sdk.wialon.com/wiki/ru/sidebar/ … ken/update
userId    Child user ID (optional,
to manage tokens of another user)

Thank you!!
Fernando.

9

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

Sorry for the insistence, but I am stuck with this and I need help, does anyone know how I can solve this problem?

10

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

ft.lussich пишет:

Hello muev, thanks for your answer, add the parameter that suggests to me anyway I keep having the same error:

https://hst-api.wialon.com/wialon/ajax. … mp;params=
{
    "callMode" : "update",
    "userId" :"022968d542574d971f042fc00 ...",
    "app":"gurtam",
    "at": "0", 
    "p":"{}",
    "dur":"10000",
    "fl":"512",
    "h":"7c781e3218f2d523c9c9a08e3812253c8CB575C4BD7415DF65BCB ..."
}


I find it strange that in the documentation it says that the parameter is optional

https://sdk.wialon.com/wiki/ru/sidebar/ … ken/update
userId    Child user ID (optional,
to manage tokens of another user)

Thank you!!
Fernando.


Good day, Fernando!

it's not correct value for "userId",  "userId" is not a session id.
First you need to login into system using valid token - the example here
After login request you will get JSON answer from server, where  parameter "eid"  is session id . This value you need to apply to any another request during session.
For example,  next you would like to execute request svc=token/update , so the request format like :
hst-api.wialon.com/wialon/ajax.html?svc=token/update&params={required_params}&sid=eid_value

Also please note token for login should has full access rights.
You can get new token with full access rights via authorization form with URL like (just send parameter access_type)
https://hosting.wialon.com/login.html?access_type=-1

Diana Cheley
Wialon Hosting Expert
Gurtam
11

Get login token with an HTTP call?

Re: Get login token with an HTTP call?

Thank you very much Chdi, now it is working!