question

moach-2000 avatar image
moach-2000 asked

VRM API Token - invalid token

Hi!

I already created an User for VRM Portal.

I also created a token but I'm currently struggeling to get access to the data.

I tried to use https://vrm-api-docs.victronenergy.com/#/operations/users/idUser/get-site-id to get some results but always error 401 (Invalid token).

I also checked some other posts but still no sucess.

Any idea and/or can someone support me?

Br, Chris

api
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

2 Answers
matt1309 avatar image
matt1309 answered ·

Hi @Moach_2000

What endpoint are you using/what curl command if you don't mind sharing it.

The endpoint should be:

https://vrm-api-docs.victronenergy.com/#/operations/users/{idUser}/get-site-id

Where {idUser] is replaced with your user ID


So the curl command would be:


curl --request GET \ --url https://vrmapi.victronenergy.com/v2/users/{idUser}/installations \ --header 'Content-Type: application/json' \ --header 'x-authorization: Bearer <bearer_token_value>'


With your bearer token in the place of <bearer_token_value> and your User id in place of {idUser}

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

moach-2000 avatar image
moach-2000 answered ·

Hi Matt1309!

Thanks for your support in this topic.

I used VRM Portal to do the tests in different combinations (https://vrm-api-docs.victronenergy.com/#/operations/users/idUser/installations):


curl --request GET \

--url https://vrmapi.victronenergy.com/v2/users/123456/installations \

--header 'Content-Type: application/json' \

--header 'x-authorization: Bearer <abc-123-xyz>'


e.g. 123456 = it's not my real user, just as an example. I used the userid which is visible in the VRM Portal in the URL (6 digits).

Reagrding the token - I created two new one (in the portal in the menu - access token; one was already there and I created two more) and tried both but always the same output (depends on which token I use for the try):


401 Unauthorized

{  "success": false,  "errors": "Invalid accesstoken received",  "error_code": "invalid_token"}


401 Unauthorized

{  "success": false,  "errors": "Token is invalid",  "error_code": "invalid_token"}


Any ideas?

Br, Chris

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

matt1309 avatar image matt1309 commented ·

Hi @Moach_2000


I think it's the User ID. I think what you're describing in the url as the User ID is actually the installation ID and not the user ID.


To get your userID try running this with your username and password ofc.


curl --request POST \ --url https://vrmapi.victronenergy.com/v2/auth/login \ --header 'Content-Type: application/json' \ --data '{ "username": "john@example.com", "password": "somepassword" }'


This will give you a new token but also tell your userid number.

0 Likes 0 ·

Related Resources

Additional resources still need to be added for this topic