REST API - Invalid Grant

Solved Locked

Hi all,

I have a demo cloud account for MobiControl and am trying to authenticate against the REST API. But I cannot get the token as the API response is:

b'{"error":"invalid_grant"}'

Here is my Python code:

import requests from requests.auth import HTTPBasicAuth
clientId = "43d..." clientSecret = "Lo6..." clientAuth = HTTPBasicAuth(clientId, clientSecret)
username = "ksemba@demo.com" userpassword = "thepassword" payload = "grant_type=password&username=" + \     username + "&password=" + userpassword
tokenURL = "https://s115236.mobicontrolcloud.com/MobiControl/api/token" headers = {"Content-Type": "application/x-www-form-urlencoded"}
r = requests.post(tokenURL,                   headers=headers,                   auth=clientAuth,                   data=payload) print(r.content)    
Edited 5 years ago
SOTI MobiControl
ANSWERS
R
RRMOD@SOTI
5 years ago (edited 5 years ago)

Hi Kurt ,

Thanks for an update. Please follow the steps below to check and create a new Admin User for your Mobicontrol account.

Please login to the Mobicontrol and Navigate to the Security Tab and look for your username and check if has the Administrator user group assigned to it under the Member section.

Solution
R
RRMOD@SOTI
5 years ago

Hi Kurt Semba,

Thanks for posting in the SOTI Central.

Can you please check if you are using a Mobicontrol user with Administrator privileges and It should be a Mobicontrol user not an Identity User.

Also, if this post has helped you in solving your inquiry, I would request you to mark the particular comment as "is solution", so others may benefit from this information.

KS
Kurt Semba
5 years ago

Hi team,

please excuse my lack of knowledge but I'm very new to the platform. How can I check whether the account I use is an admin account and if not, how do I create one? 

Also: I'm pretty sure I only have an Identity User. When I log in manually though the browser, I use https://companyname.identity.soti.net. Then I clik on the MobiControl app icon to launch it.

I could this account as a demo / test account with a 30-day trial license and I need to test some API based integrations.

Thanks again

KS
Kurt Semba
5 years ago

Hi Team,

thank you very much for providing your guidance. This solved my problem: the user account I used was not an administrator. By adding a new user and adding it to the Administratiors group I could use that new admin user in my API token request and successfully retrieved the access_token. 

Great support - highly appreciated!

Kurt