cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API - Can't even login ?

RGenin
Trusted Contributor

Hello, 

 

We are trying to test the API features to generate reports.

However, it seems we can't even pass the login phase...

 

All is configured according to the exemple, but looking at the logs we saw that :

2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Start token request
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Start client validation
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Start parsing Basic Authentication secret
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Start parsing for secret in post body
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - No secret in post body found
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Start parsing for X.509 certificate
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - client_id is not found in post body
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Parser found no secret
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - No client secret found
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - End token request
2019-08-21 16:27:20,449 [64] INFO  /LM/W3SVC/1/ROOT/UAS-1-132108916563800795 - System.Reflection.RuntimeAssembly - Returning error: invalid_client

No secret in post body ?

No client_id in post body??

 

Config in wwwroot\UAS\config.json

      "HopexAPI": {
        "Enabled": 1,
        "Flow": 4,
        "ClientId": "HopexAPI",
        "Scopes": "read;write;offline_access;openid",
        "ClientSecret": "secret",
        "ClientName": "Hopex WebServices"

Result and poke with PostMan

image.png

 

 

Any idea ?

 

Thanks a lot, 

Raphaël. 

4 Replies

RGenin
Trusted Contributor

Hello, 

 

Thanks for the reply but unfortunately it is exactly what I have (see screenshots).

Would you have any other clue ?

 

Thanks

Before making any call to a REST API in HOPEX you need to get an authentication bearer token. This token will allow you to access the data based on your credentials. Prior to continue make sure you have at leat the there following information :

  • the login of the user
  • the password of the user
  • the absolute idenfier of the environment you want to access to.

To get a token make a REST API call to the following URL

https://<<my server here>>/UAS/connect/token

 

You can make this call with a tool like Postman for instance. the request will be a POST request to which you will provide a set of parameters in the body.

 

Selection for the body option : x-www-form-urlencoded

 

The parametes for the body are :

grant_type: password          (remove the space between the : and the p)
scope:hopex openid read write
username:<<my hopex login here>>
password:<<my hopex password here>>
client_id:HopexAPI
client_secret:secret
environmentId:<<my hopex environment absolute identifier>>

 

Need to know how to get the environmentID ? Read this post

 

Some of the option can be different than in this example depending on the installation option you have done.

 

Body Response format :

{
"access_token""9f6ccf75bafa2c84a507842174205f8b",
"expires_in"3600,
"token_type""Bearer"
}

 

https://community.mega.com/t5/REST-API/Get-a-bearer-token-from-UAS-for-REST-API-call/m-p/21372#M2

 

ilvetz
Super Contributor

Hi.

We want to use Web APIs. Could you please link us to the example you are talking about? I can't find how to configure the API user.

Thanks.