I'd like to call the CloudPC rest API using a C# client. The C# client is in the beta nuget package Microsoft.Graph.Beta. Here is a sample client that illustrates how to authenticate using the the non-beta client.
// Build a client application.
IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
.Create("INSERT-CLIENT-APP-ID")
.Build();
// Create an authentication provider by passing in a client application and graph scopes.
DeviceCodeProvider authProvider = new DeviceCodeProvider(publicClientApplication, graphScopes);
// Create a new instance of GraphServiceClient with the authentication provider.
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
When I try to use that sample client with the non-beta nuget I get discover I cannot resolve DeviceCodeProvider. So what I can I use instead of DeviceCodeProvider?
Michael Mainer tells me I can use DeviceCodeCredential which does resolve. Still the sample is not yet functional. So now I'm trying to adapt this sample Michael sent me.
Michael also sent me a pointer to LinqPad samples which are useful for poking at the API.
I have a bunch of queries setup MIchaelMainer/graph-test-harness: This repository contains samples for a Microsoft Graph test harness to quickly and easily test SDKs (github.com) to help try out the libraries. I have an option for DeviceCodeCredential.
That is in the Microsoft.Graph.Auth package, which will be deprecated soon. If you use the preview version of Microsoft.Graph.Beta, which takes a dependency on preview Microsoft.Graph.Core, you'll be able to use the Azure.Identity DeviceCodeCredential which is the equivalent of DeviceCodeProvider and is the future of auth in the graph SDK.
https://github.com/andrueastman/TokenCrendentialAuthProvider/blob/master/TokenCredentialSample/Program.cs
The preview version of Microsoft.Graph (4.x.x-preview), Microsoft.Graph.Beta (4.x.x-preview), and Microsoft.Graph.Core (2.x.x-preview) supports Azure.Identity TokenCredential. This will allow you to use the same auth library for both Azure and Microsoft Graph development work.
using Microsoft.Graph;
using Azure.Identity;
DeviceCodeCredentialOptions options = new()
{
ClientId = "public_clientid",
TenantId = "tenantId"
};
GraphServiceClient client = new (new DeviceCodeCredential(options));
Related
We were using KeyVaultClient and KeyVaultCredentials classes as provided in the SDK -
com.microsoft.azure
azure-keyvault
Recently got a warning that this library is deprecated and is divided into 3 libraries - azure-keyvault-security-certificates, azure-keyvault-security-secrets and azure-keyvault-security-keys but I could not find these classes in any of the libraries. Am I still supposed to use azure-keyvault for these classes?
Depending on what functionality of Key Vault you want to use, instead of a KeyVaultClient you would use a CertificateClient, KeyClient or SecretClient.
For example, you can instantiate a simple client the following way:
KeyClient keyClient = new KeyClientBuilder()
.vaultUrl("<your-key-vault-url>")
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
There are many more methods you can use in a client builder to customize the resulting client.
As for a replacement for KeyVaultCredentials, client builders allow you to authenticate the client to be created via the credential() method, so you can choose the way that best fits your solution. For more information on the available credential types and their diffecences you can check the Azure Identity README.
I am quite new in the orocommerce ecosystem, and I would like to generate API client librairies automatically for orocommerce API (frontend and backend). The objective is to build my own UI.
I found some dependencies on NelmioApiDocBundle than could potentially generate swagger file, but I hit multiple problems:
this is a quite old version, that only support swagger 1.2
the generated file (using symfony run php bin/console api:swagger:dump /tmp/api/) seems not working with swagger codegen "as is"
all the part of the API seems not written using NelmioApiDocBundle annotation
I am wondering if there is an other mechanism to generate API client librairies for orocommerce. I would like a SDK for typescript.
Thanks in advance for your answer.
Right now, the only supported swagger version is 1.2, as you stated.
By default, the api:swagger:dump command works with an outdated API, to generate data for the current API, run it with --view=rest_json_api option:
api:swagger:dump --view=rest_json_api
As an alternative to the API client generation, as Oro API strictly follows JSON.API standard, you can use many existing client libraries, compatible with the JSON.API specification. The list of Typescript implementations can be found at the official website: https://jsonapi.org/implementations/#client-libraries-typescript
I am trying to make one simple application in Xamrin android using
Google Vision API.
What I did is,
Installed
Google cloud vision v1,
Google.Apis.Auth.OAuth2;
Newtonsoft.Json;
in my xamarin.android project from NuGet manager.
I created
API Key,
Service Account,
OAuth 2.0 client IDs
from google cloud console.
I created GOOGLE_APPLICATION_CREDENTIALS (Environmenta variable)
and linked those Json file (both service account and
OAuth 2.0 client IDs json) tried both.
Then I just copied code from google vision API documentaion.
// Load an image from a local file.
var image = Image.FromFile(filePath);
var client = ImageAnnotatorClient.Create();
var response = client.DetectLogos(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
textView.Text = (annotation.Description);
}
everytime i try to compile the program it throws exception
System.InvalidOperationException: The Application Default
Credentials are not available. They are available if
running in Google Compute Engine. Otherwise,
the environment variable GOOGLE_APPLICATION_CREDENTIALS
must be defined pointing to a file defining the credentials.
See https://developers.google.com/accounts/docs/
application-default-credentials for more information.
I need help to set default credentials, I tried many links from google
documentation but no luck.
has anyone got any idea how to handle this exception.
We have a WebAPI project that exposes a few controllers doing tasks with TFS. We usually connect like this:
var server =
new Microsoft.TeamFoundation.Client.TfsConfigurationServer(new Uri("http://XXX"));
server.EnsureAuthenticated();
My understanding of this is: It works because somehow, my IIS express runs the application under my account. Somehow the TfsConfigurationServer can read my credentials and use them when querying/writing over TFS.
Now, the problem comes when I try to host this in a real webserver. Comes back with:
"TF30063: You are not authorized to access http://XXX"
I have activated Windows Authentication, so if I print:
User.Identity.Name -> (domain\\my_user).
Even being there my username, it does not seem to be enough. I assumed the TfsConfigurationServer class can't get the credentials, so I've tried to be more explicit:
new TfsConfigurationServer(new Uri("XXX"), CredentialCache.DefaultNetworkCredentials);
Didn't work either. I was assuming that, given that I have Windows Authentication activated and Anonymous deactivated, DefaultNetworkCredentials would work. Reading more I've found also:
var id = (WindowsIdentity)User.Identity;
using (id.Impersonate())
{
return myOperation.CallMethod();
}
But same result. Inside CallMethod() I was calling again TfsConfigurationServer with the DefaultNetworkCredentials. The impersonation seems to be working fine, but authentication to TFS fails anyway.
How can I provide the credentials to TFS from the currently logged in user in the server via Windows Auth?. How does it work in local?.
Note: I have been reading also about TFS Impersonation (https://blogs.msdn.microsoft.com/taylaf/2009/12/04/introducing-tfs-impersonation/). My problem is that it seems to require some permissions set in the server, I'd love to mimic that behavior without using this technique, not sure if that's possible.
Give a try with below code:
var tfsCredentials = new TfsClientCredentials(System.Net.CredentialCache.DefaultCredentials, true);
TfsTeamProjectCollection teamCollection = new TfsTeamProjectCollection(new Uri("http://tfssite.com/tfs/" + Collection), tfsCredentials);
I've got ServiceStack working nicely on the server and with a Windows test client, and now need to get it working in my Mono For Android application.
I've downloaded the following:
ServiceStack.Common.dll
ServiceStack.Interfaces.dll
ServiceStack.Text.dll
from the github tip, and added references to these in my Mono for Android project.
However, we need to use authentication, so need the ServiceStack.ServiceInterface.Web namespace to be available for the client, so I can do the following:
var c = new JsonServiceClient("http://localhost:53434");
var authResponse = c.Get(new Auth { UserName = "myusername", Password = "password", RememberMe = true });
Looking at my working test client, Auth is defined in ServiceStack.ServiceInterface.dll, so presumably I need to get hold of this DLL, or its source and compile it in my project.
Am I on the right lines here, or is there a simpler way to set things up? I've searched around but can't find a good resource on how to use ServiceStack with Mono For Android - if there is one, please feel free to point me to it!
I note this StackOverflow indicates I'm on the right lines - all I might need is ServiceStack.ServiceInterface.dll compiled for Mono For Android.
James
You shouldn't have to compile the server ServiceStack.ServiceInterface.dll for use in any client library as there is a copy of the Auth DTOs is also available in the ServiceStack.Common.dll client library at ServiceStack.Common.ServiceClient.Web.AuthDtos.cs.
This is possible since both server and client DTOs generate the same wireformat.