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 4 years ago
SOTI MobiControl
ANSWERS
R
RRMOD@SOTI
4 years ago (edited 4 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.

 

To create a new user account with Administrator privileges for the SOTI MobiControl console and set its permissions:

  1. On the All Platforms tab, select the Security tab.
  2. Select the Manage Users option from the left pane of the console.
  3. Click Add and select User from the drop-down list.
  4. Enter a username and a password for the new user.
  5. Under the Membership section, place the new user ( Administrator ) in a user group by moving a user group from Available User Groups to Selected User Groups using the arrows.
    1. Note: Alternatively, you can apply permissions to the new user individually, without placing it in a user group. Under the Global Permissions section, use the Allow and Deny boxes to set permissions for access to the SOTI MobiControl console but doing this you may not be able to access the API's. Unspecified permissions will default to Deny. See Global Permissions for information on specific permissions.
  6. Click Save in the bottom right corner of the SOTI MobiControl console.

After creating a new Administrator User and if have cloud instance. Then, Please create a support case(click here) or call SOTI Support team(click here) to add API Client and if the above does not work. Kindly contact SOTI Support team(click here) to log a case.

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.

 

Solution
R
RRMOD@SOTI
4 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
4 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
4 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