Why can't I create a managed device on Intune? - api

I am trying to create a managed device in Intune but I am getting different errors.
This is the documentation I am using https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/intune_devices_manageddevice_create.
I am testing the functionality using Graph Explorer so I do not need the authorization token and the account I am logged into is the global administrator and has the appropriate delegated permission enabled 'DeviceManagementManagedDevices.ReadWrite.All'.
When I try the first request /users/{usersId}/managedDevices I get a 403
An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000.
If I try /deviceManagement/managedDevices I get 400
No OData route exists that match template
I am signed up for a free trail for Intune and Azure AD if this makes any difference.
What could I be missing?
The request body I based off the example in the documentation for create managedDevice. I also tried removing the odata type but it makes no difference.
An example I have tried
{
"id": "5h5b3fab-0169-45de-9aad-3d928ebbe1a0",
"userId": null,
"deviceName": "newIntuneDev",
"deviceActionResults": [],
"enrolledDateTime": "2018-02-19T11:04:24.242385Z",
"lastSyncDateTime": "2018-01-03T14:01:45.1553437Z",
"operatingSystem": "Android",
"complianceState": "compliant",
"jailBroken": "false",
"managementAgent": "mdm",
"osVersion": "7.0",
"easActivated": true,
"easDeviceId": "DFC17B28459230B3",
"easActivationDateTime": "2018-01-19T11:05:11.4483412Z",
"azureADRegistered": true,
"deviceEnrollmentType": "userEnrollment",
"activationLockBypassCode": null,
"emailAddress": null,
"azureADDeviceId": "89f65205-72af-4830-a9b1-ebcd3160476f",
"deviceRegistrationState": "registered",
"deviceCategoryDisplayName": null,
"isSupervised": false,
"exchangeLastSuccessfulSyncDateTime": "0001-01-01T00:00:00Z",
"exchangeAccessState": "none",
"exchangeAccessStateReason": "none",
"remoteAssistanceSessionUrl": "",
"remoteAssistanceSessionErrorDetails": "",
"isEncrypted": false,
"userPrincipalName": null,
"model": "SM-G930F",
"manufacturer": "samsung",
"imei": "539467078998547",
"complianceGracePeriodExpirationDateTime": "9999-12-31T23:59:59.9999999Z",
"serialNumber": "T58H52RP9KN",
"phoneNumber": null,
"androidSecurityPatchLevel": "2018-01-01",
"userDisplayName": null,
"configurationManagerClientEnabledFeatures": {
"inventory": false,
"modernApps": false,
"resourceAccess": false,
"deviceConfiguration": false,
"compliancePolicy": false,
"windowsUpdateForBusiness": false
},
"wiFiMacAddress": "4C6641183631",
"deviceHealthAttestationState": null,
"subscriberCarrier": "",
"meid": "659467078998547",
"totalStorageSpaceInBytes": 0,
"freeStorageSpaceInBytes": 0,
"managedDeviceName": "newDevice",
"partnerReportedThreatState": "unknown"
}

This (https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/intune_devices_manageddevice_create) is a documentation error. API does not support creation of managedDevice. You would need to MDM enroll a device into Intune to see data populated under ~/managedDevices API.
Signup for a free Intune trial subscription
Set MDM authority - https://learn.microsoft.com/en-us/intune/mdm-authority-set
Enroll a device -
https://www.microsoft.com/itshowcase/Article/Video/634/Enroll-your-mobile-device-in-Microsoft-Intune-for-corporate-access
Once successfully enrolled, device should show up under ~/managedDevices
Thanks,
Alemeshet Alemu - MSFT

Related

Rest API for Authentication with nHost

So I know there's several SDK packages for many languages available for nHost, however I need to create my own interface to the system since the language I'll be using isn't typical.
I basically just need to know how to interact with authentication endpoints, send a users un/pw and recieve a JWT token. I've been successfully able to do this with aws Cognito, but I'd like to explore this instead.
I'm also not sure if I'm using the right base url, here's my thought so far:
https://kbvlufgpikkxbfkzkbeg.nhost.run/auth/login
So I would POST to there with some json in the body with the un/pw stuff, and the response should be the jwt token right?
I get a "resource does not exist" response from the above, however, so obviously I'm not forming the url correctly in the first place.
Thanks for the help!
Nhost supports multiple sign-on methods.
For example, using the email+password method, you would send:
POST https://xxxxxxxxxxxxx.nhost.run/v1/auth/signin/email-password
{"email":"foo#example.com","password":"bar"}
and the response:
{
"session": {
"accessToken": "somejwt....",
"accessTokenExpiresIn": 900,
"refreshToken": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"user": {
"id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"createdAt": "2022-09-17T19:13:15.440221+00:00",
"displayName": "foo#example.com",
"avatarUrl": "",
"locale": "en",
"email": "foo#example.com",
"isAnonymous": false,
"defaultRole": "user",
"metadata": {},
"emailVerified": true,
"phoneNumber": null,
"phoneNumberVerified": false,
"activeMfaType": null,
"roles": [
"user",
"me"
]
}
},
"mfa": null
}
The JWT is short-term, when it expires, the refresh token is used to get a new one.
The Nhost JavaScript SDK handles it automatically for you, that's a big benefit to the platform (in addition to being integrated with Hasura). If you are trying to port it to another unsupported language, you'd have to reimplement it. Probably by reading the library and/or running one of their sample client application and reverse-engineering the HTTP over the wire.

Token based authentication for log-in in PyQT Python based Desktop Application

The application I am developing is team collaboration tools. This software should prevent unauthorized access. In order to implement this, I've used user and password-based authentication with two roles available - standard user and administrator.
This was implemented entirely in Python by using SQLAlchemy for interacting with the database, and PyQt for the user interface. For authentication, I am calling User Management System to get a token:
Request Body:
{
"username": "messaing_platform",
"password": "132465"
}
Response Body:
{
"apiData": {
"navigationList": [],
"userId": "messaing_platform",
"userName": "messaing_platform",
"email": "messaing_platform#erainfotechbd.com",
"cellNo": "01255",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOiJjcyIsIm5iZiI6MTY1OTUyNzcxOCwiZXhwIjoxNjYwMTMyNTE4LCJpYXQiOjE2NTk1Mjc3MThasdasd9.4lkEv-TpwIyYcldXfKucy3ynewhbuUFgjtdnKm7ymjE",
"page": 0,
"pageSize": 0,
"searchString": null,
"skip": 0
},
"message": "Record has been saved.",
"isExecute": true,
"totalRecord": 0
}
Now, I want to save this token in the PyQT user interface and if the token is expired, then the user should be logged out from the application. How can I do that?

azureStorageUri not created when create mobileAppContentFile in Microsoft Intune

I want to create a mobileAppContentFile. For this I make a POST request to:
https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/0122f94e-45c4-458a-a25a-c08135a036fc/microsoft.graph.windowsMobileMSI/contentVersions/1/files
with this request body:
{
"#odata.type": "#microsoft.graph.mobileAppContentFile",
"azureStorageUri": "https://NAME.blob.core.windows.net/intune/TestApp.msi",
"name": "TestApp.msi",
"isCommitted": false,
"uploadState": "azureStorageUriRequestPending"
}
I receive 201 Created response but azureStorageUri is null:
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#deviceAppManagement/mobileApps('0122f94e-45c4-458a-a25a-c08135a036fc')/microsoft.graph.windowsMobileMSI/contentVersions('1')/files/$entity",
"azureStorageUri": null,
"azureStorageUriExpirationDateTime": null,
"createdDateTime": "0001-01-01T00:00:00Z",
"id": "ca57173c-5f67-4048-90bf-3bac136de964",
"isCommitted": false,
"manifest": "bWFuaWZlc3Q=",
"name": "TestApp.msi",
"size": 0,
"sizeEncrypted": 0,
"uploadState": "azureStorageUriRequestPending"
}
What could be the problem?
Fisrt,as #Marc Lafleur said, you need to upload the file to Azure sotrage first and then provide the required Property value of them.
Second,In your request body, you didn't fill with full required properties.
Follow this example to create one mobile app content file :
POST https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/{mobileAppId}/contentVersions/{mobileAppContentId}/files
Content-type: application/json
Content-length: 342
{
"#odata.type": "#microsoft.graph.mobileAppContentFile",
"azureStorageUri": "Azure Storage Uri value",
"isCommitted": true,
"name": "Name value",
"size": 4,
"sizeEncrypted": 13,
"azureStorageUriExpirationDateTime": "2017-01-01T00:00:08.4940464-08:00",
"manifest": "bWFuaWZlc3Q=",
"uploadState": "transientError"
}

Yodlee AddSiteAccount1 issues

I am trying to verify various MFA based accounts Yodlee API by performing following steps:
Successful call to addSiteAccount1
In response, it does return siteAccountId
In response, it also provides site refresh status that REFRESH_TRIGGERED
if resp['siteRefreshInfo']['siteRefreshMode']['refreshMode'] == 'MFA' and
resp['siteRefreshInfo']['isMFAInputRequired'] == True and
resp['siteRefreshInfo']['siteRefreshStatus']['siteRefreshStatus'] ==
'REFRESH_TRIGGERED'
Now, calling getMFAResponseForSite repeatedly together with getSiteRefreshInfo results into initially code 801 and than 508 eventually timeout.
Eventually, I come out of the loop with result isMessageAvailable: True
{u'itemId': 0,
u'retry': False, u'timeOutTime': 99880, u'memSiteAccId': 10144098,
u'errorCode': 0, u'isMessageAvailable': True, u'fieldInfo':
{u'questionAndAnswerValues': [], u'numOfMandatoryQuestions': -1,
u'mfaFieldInfoType': u'SECURITY_QUESTION'}}
The only concern I have is that it provides mfaFieldInfoType, but it doesn't provide the actual question.
Couple questions:
a. How do I retrieve proper MFA question(s) for the site?
b. If user is initially coming into system and would like to link account more than couple second wait for user will kill the experience - so what's the recommended time period to be allowed to get MFA question?
c. Is this due to development vs. production environment difference?
d. I can retrieve account and holdings details for account, however than the account results in NON_REFRESHABLE state.
After calling addSiteAccount1 API, you get siteAccountId for an account.
Pass the siteAccountId to getMFAResponseForSite API and keep polling until you get the MFA form. then pass the MFA form with valid values to putMFARequestForSite API.
Please refer to our API flow- https://developer.yodlee.com/Aggregation_API/Aggregation_Services_Guide/API_Flow/Add_Site_Account
Blockquote
Sample response-
{ "isMessageAvailable": true, "fieldInfo": {
"questionAndAnswerValues": [
{
"question": "What is the name of your state?",
"questionFieldType": "label",
"responseFieldType": "text",
"isRequired": "true",
"sequence": 1,
"metaData": "QUESTION_1"
},
{
"question": "What is the name of your first school",
"questionFieldType": "label",
"responseFieldType": "text",
"isRequired": "true",
"sequence": 2,
"metaData": "QUESTION_2"
}
],
"numOfMandatoryQuestions": 2,
"mfaFieldInfoType": "SECURITY_QUESTION" }, "timeOutTime": 97340, "itemId": 0, "memSiteAccId": 10003775, "retry": false }

How to get track ID from URL using the SoundCloud API

How can I get a track ID from a track URL using the SoundCloud API?
You didn't specify a language in your question, so I'm just going to provide a high-level answer.
Use the resolve endpoint. I'm using this URL as an example:
https://soundcloud.com/msmrsounds/ms-mr-hurricane-chvrches-remix
HTTP GET: https://api.soundcloud.com/resolve.json?url=https%3A%2F%2Fsoundcloud.com%2Fmsmrsounds%2Fms-mr-hurricane-chvrches-remix&client_id=[your_client_id]
The resulting JSON:
{
"status": "302 - Found",
"location": "https://api.soundcloud.com/tracks/147986343.json?client_id=[YOUR client_id]"
}
That numerical value is the track_id. You can just stop here or hit that endpoint you just got back for more information:
{
"kind": "track",
"id": 90787841,
"created_at": "2013/05/05 00:15:40 +0000",
"user_id": 7853935,
"duration": 188333,
"commentable": true,
"state": "finished",
"original_content_size": 35031144,
"last_modified": "2014/09/30 05:53:10 +0000",
"sharing": "public",
"tag_list": "MSMR CHVRCHES \"Secondhand Rapture\" Remix Hurricane",
"permalink": "ms-mr-hurricane-chvrches-remix",
"streamable": true,
"embeddable_by": "all",
"downloadable": true,
"purchase_url": null,
"label_id": null,
"purchase_title": null,
"genre": "",
"title": "MS MR - Hurricane (CHVRCHES remix)",
"description": "MS MR - Hurricane (CHVRCHES remix)\r\n\r\n\r\n",
"label_name": "",
"release": "",
"track_type": "",
"key_signature": "",
"isrc": "",
"video_url": null,
"bpm": null,
"release_year": null,
"release_month": null,
"release_day": null,
"original_format": "wav",
"license": "all-rights-reserved",
"uri": "https://api.soundcloud.com/tracks/90787841",
"user": {
"id": 7853935,
"kind": "user",
"permalink": "msmrsounds",
"username": "MSMR",
"last_modified": "2014/08/04 09:03:56 +0000",
"uri": "https://api.soundcloud.com/users/7853935",
"permalink_url": "http://soundcloud.com/msmrsounds",
"avatar_url": "https://i1.sndcdn.com/avatars-000037198343-2lptmy-large.jpg?86347b7"
},
"permalink_url": "http://soundcloud.com/msmrsounds/ms-mr-hurricane-chvrches-remix",
"artwork_url": null,
"waveform_url": "https://w1.sndcdn.com/56LCadzDEBZn_m.png",
"stream_url": "https://api.soundcloud.com/tracks/90787841/stream",
"download_url": "https://api.soundcloud.com/tracks/90787841/download",
"playback_count": 1672227,
"download_count": 18494,
"favoritings_count": 20426,
"comment_count": 464,
"attachments_uri": "https://api.soundcloud.com/tracks/90787841/attachments",
"policy": "ALLOW"
}
Since the SoundCloud API is indefinitely not accepting new registrations, here's one alternative solution. This URL will provide you with a wide/short embedded player:
https://w.soundcloud.com/player/?url= + URL of track
Example: https://w.soundcloud.com/player/?url=https://soundcloud.com/chrisbjerken/picking-up-the-pieces
This works for both a single track or a playlist.
So my final code looks like this. Thank you guys for the help to get this working.
include_once('../Services/Soundcloud.php');
$client = new Services_Soundcloud('CLIENT_ID', 'CLIENT_SECRET');
$track_url=$_POST['trackurl'];
$track_url=str_replace("https://soundcloud.com/USERNAME/","",$track_url);
$track = json_decode($client->get("tracks/".$track_url));
$track_id=$track->id;
echo $track_id;
In The Meantime Writing This Answer The CLIENT_ID Is Close
Due to the high amount of requests recently received, we will no longer be processing API application requests at this time. We are working to re-evaluate our process to make it more efficient.
See Here
I Solved This Issue With My Laravel Project Like This
first I Made This Function To Get The Real Content
public function getLessonUrl($lessonId = null)
{
//Get the SoundCloud URL
$validUrl = 'https://soundcloud.com/al-hazme';
$result = stripos($lessonId, $validUrl);
if (strpos($lessonId, $validUrl) !== false) {
//Get the JSON data details with embed code from SoundCloud oEmbed
$getValues = #file_get_contents('http://soundcloud.com/oembed?format=js&url=' . $lessonId . '&color=%234274e3&auto_play=false&hide_related=true&show_comments=false&show_user=false&show_reposts=false&show_teaser=true&show_artwork');
if ($getValues === false) {
return 'حدث خطأ اثناء تحميل الدرس نرجو منك التأكد من اتصال الانترنيت لديك او حدث الصفحة';
}
//Clean the Json to decode
$decodeiFrame = substr($getValues, 1, -2);
//json decode to convert it as an array
$jsonObj = json_decode($decodeiFrame);
//echo $jsonObj->html;
$lessons = str_replace('height="400"', 'height="90"', $jsonObj->html);
return $lessons;
} else {
return 'لايوجد استماع لهذا الدرس';
}
}
Then I Made Another Function To Crap The Id Using Str Facade Methods
use Illuminate\Support\Str;
public function soundCloudId($url) {
$do = $lesson->getLessonUrl($lesson->url_link);
$getTrickId = Str::after($do,'tracks%2F');
$substr = Str::substr($getTrickId,0,9);
echo $substr = // 367893857
}
It May Help Or Give You Clue
I know this is kinda late but i faced the same issue yesterday and found a new (undocumented) endpoint that you can use.
https://api-widget.soundcloud.com/resolve?url=SOUNDLCOUD_URL&format=json&client_id=CLIENT_ID
You can find your CLIENT_ID by looking at the Network Inspector in the DevTools and select the XHR filter while browsing the SoundCloud website.
I think this is sufficient until the official APIs are usable again.