As part of an Azure AD Graph call, I have the following request.Content:
var requestString = "{\"groupId\":\"xxxx\",\"memberId\":\"yyyy\"}";
request.Content = new StringContent(requestString, Encoding.UTF8, "application/json");
Where xxxx is the guid of the group and yyyy is the guid of the user. This works. Returns true.
Now I would like to be able to send a similar request that sends the names of the group and the user instead of guids. That is:
var requestString = "{\"groupId\":\"webdevs\",\"memberId\":\"bob\"}";
request.Content = new StringContent(requestString, Encoding.UTF8, "application/json");
This call does not work and I realize this might not be possible. Maybe I need to fetch the guids by the user/group names, but I'm not sure how to do that either.
Any help?
Thanks!
The IsMemberOf REST only supports to request using the groupId and memberId like below:
You were right, we can get the groupId first via the group name then call this REST API to check the membership. And we can use the $filter parameter in the REST like below get the guids of user/group via their name:
Get https://graph.windows.net/adb2cfei.onmicrosoft.com/groups?api-version=1.6&$filter=displayName+eq+'GroupName'
Get https://graph.windows.net/adb2cfei.onmicrosoft.com/users?api-version=1.6&$filter=displayName+eq+'UserName’
You can refer this REST about more detail from here.
Related
Below is the code that I have:
List<PatchOperation> patchOperations = new List<PatchOperation>();
patchOperations.Add(PatchOperation.Replace("/endpointId", 100));
string id = "id1";
PartitionKey partitionKey = new PartitionKey("partitionkey1");
await _container.PatchItemAsync<Watermark>(id,
partitionKey,
patchOperations);
I am expecting to get endpointId property to be replaced with 100.
However, I am faced with Message: {"Errors":["One of the specified inputs is invalid"]}.
May I check which part am I missing or do I have to wait for patch private preview feature to be enabled for my cosmos db?
For anyone else landing here looking for the reason why Cosmos might respond with One of the specified inputs is invalid for other request types, you may need to rename your Id property to id lower-cased or add an attribute:
[JsonProperty("id")]
public string Id { get; set; }
id attribite in cosmos db is case sensitive. Try to replace your id getter setter with "id" this case.
Even though error says "One of the specified inputs is invalid" you should see a status code 400 which indicates Bad Request. So Private Preview feature needs to be enabled for your account.
You can also enable Patch with your emulator by adding EnablePreview when you start the emulator,
.\CosmosDB.Emulator.exe /EnablePreview
In order to get it enabled you can register using this form and it should be done in 15-20 minutes. Let me know if that does not work
Another reason for this error message could be if you forget the forward slash before your property name:
await container.PatchItemAsync<T>(item.Id, new PartitionKey(item.PartitionKey), new[]
{
PatchOperation.Add("isDeleted", true),
PatchOperation.Add("ttl", DefaultTtl),
});
The correct code would be:
await container.PatchItemAsync<T>(item.Id, new PartitionKey(item.PartitionKey), new[]
{
PatchOperation.Add("/isDeleted", true),
PatchOperation.Add("/ttl", DefaultTtl),
});
I'm struggling to figure out how the smart device management API works.
The end goal is to fetch a status of my nest thermostat on an ongoing basis for logging purposes, using service account credentials:
await using var stream = new FileStream(path, FileMode.Open, FileAccess.Read);
var credential = GoogleCredential.FromStream(stream)
.CreateScoped(SmartDeviceManagementService.ScopeConstants.SdmService);
var service = new SmartDeviceManagementService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential
});
This appears to be correct, however when I try and call service.Enterprises.Devices.List() it requires a parent ID in the format of "^enterprises/[^/]+/devices/[^/]+$ But I do not know how to acquire this parent ID to begin testing my code.
Does anyone know how to obtain these strings which seem to be necessary to use the API?
Have you registered from a project id via the Device Access Console?
https://console.nest.google.com/device-access
That seems to be what you're looking for.
I've been searching on the best way to get information my azure auth from facebook.
My app is getting the authentication and the id of the user! I am not sure what code I need next in order to get the information.
So far I have this
if (authenticated)
{
var client = new HttpClient();
var fbUser = await client.GetAsync(Appurl+".auth/me");
var response = await fbUser.Content.ReadAsStringAsync();
var jo = JObject.Parse(response);
var userName = jo["'typ':'user_id'"].ToString();
}
So far all the answers have left me clueless
I just need this to return name email and other Items I want.
I am sure this is an Json Parsing the wrong issue but I am not sure.
Please help!!!
I just need this to return name email and other Items I want. I am sure this is an Json Parsing the wrong issue but I am not sure.
If you visit https://yourmobileapp .azurewebsites.net/.auth/me from browser, and login with your FaceBook account. Then you could get the Json structs as following. It is a JArray . So please have a try to use following code, it works correctly on my side.
var ja = JArray.Parse(response);
var id = ja[0]["user_id"];
Before that we need to add email scope on the Azure portal, about how to add email scope, please refer to the screenshot.
I am using Auth0, And I want to retrieve all users of my client application.
Below is my code:
var apiClient = new ManagementApiClient("<<Token>>", new Uri("https://<<Domain>>/api/v2/users"));
var allClients = await apiClient.Users.GetAllAsync();
I am using token which includes Read:User permission in auth0.
But I am getting below error,
Path validation error: 'String does not match pattern ^.+\|.+$: users'
on property id (The user_id of the user to retrieve).
I read this arrticle, But I am not understanding, What changes I need to make in auth0.
https://auth0.com/forum/t/auth-renewidtoken-returns-a-user-id-validation-error/1151
What changed I need to make to solve it?
You need to create the ManagementApiClient in one of the following ways:
// Pass the base Uri of the API (notice it does not include the users path)
var api = new ManagementApiClient("[token]", new Uri("https://[account].auth0.com/api/v2"));
or
// Pass only the domain as a string
var api = new ManagementApiClient("[token]", "[account].auth0.com"));
You're including /users in the base API path which will then cause errors, like the one you observed.
Here I am using asp.net web to display Google analytic data. I am successfully able to get access token using oauth2.0. Using access token I am also get account information.
Here I want to get Google analytic data using access token. Please share link with me to get data using access token.
I have seen following code
http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/Analytics_DataFeed_Sample/dataFeed.cs
But don't want to use it because here I have to pass user name and password:
private const String CLIENT_USERNAME = "INSERT_LOGIN_EMAIL_HERE";
private const String CLIENT_PASS = "INSERT_PASSWORD_HERE";
Let me know any way to get analytic data using access token.
After long work will get success.....
Here is Oauth playground made by Google developer from you can test your data
https://code.google.com/oauthplayground/
I just Oauth 2.0 for retrieve access token information after that I am using following URL for getting analytic information.
https://developers.google.com/analytics/devguides/reporting/core/v2/gdataReferenceDataFeed
you need to pass access token with your URL ie :
https://www.googleapis.com/analytics/v2.4/data?ids=ga:12345&metrics=ga:visitors,ga:bounces&start-date=2012-07-01&end-date=2012-07-25&access_token=ya29.AHES6ZTzNR6n6FVcmY8uar6izjP9UGeHYNO5nUR7yU2bBqM
Best of luck Enjoy coding..
You can try with following code
string ClientId = "CLIENTID"
string ClientSecret = "CLIENTSECRET"
var Client = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, ClientSecret);
var Auth = new OAuth2Authenticator<NativeApplicationClient>(Client, Authenticate);
var Service = new AnalyticsService(Auth);
var Request = Service.Data.Ga.Get("profileID", StartDate, EndDate, "Matrix");
Request.MaxResults = 1000;
Request.Dimensions = "Dimensions";
var Result = Request.Fetch();