I am trying to follow this PowerBI embedded example and am getting an error:
'PowerBIToken' does not contain a definition for 'CreateProvisionToken'
This MSDN article describes the CreateProvisionToken() method.
I installed latest Microsoft.PowerBI.Core and Microsoft.PowerBI.Api using NuGet package manager
included Microsoft.PowerBI.Security and Microsoft.PowerBI.Api.V1 in my project.
I also tried changing CreateProvisionToken() part to the following:
var credentials = new TokenCredentials(accessKey, "AppKey");
var client = new PowerBIClient(credentials);
var devToken = PowerBIToken. CreateDevToken(reportID, workspaceID);
using (client)
{
var embedToken = PowerBIToken.CreateReportEmbedToken(
collectionName,
workspaceID,
reportID);
var embedTokenString = embedToken.Generate(accessKey);
}
Which generates a token which "looks about right", but using this token in the example html in the end of the article results in an error This content is not available when rendering the report.
What am I missing?
The latest version of Power BI embedded simplifies the authentication mechanism by only support one embedded token, no other tokens anymore from Power BI blog:
https://powerbi.microsoft.com/en-us/blog/what-s-new-and-what-s-next-for-power-bi-embedded-july-2016/
We have simplified the way developers authenticate their calls to Power BI. From today on, app tokens will only be used to authenticate embedding requests and other client side requests that may be added in the future. All calls to our REST APIs will be authenticated using our API keys directly. This eliminates the need to generate app tokens each time you want to call the REST API.
You need follow up the example from Microsoft:
https://github.com/Azure-Samples/power-bi-embedded-integrate-report-into-web-app/blob/master/EmbedSample/Controllers/DashboardController.cs
Related
I want to send chat messages using AppSync from a .net Core backend, using the nuget package AWSSDK.AppSync. But I Can't find any guide or sample code to do so.
I'm trying to code something similar to the AWS mobile sample application AppSync Chat Starter Angular. The goal is to have a conversation between the user (on a browser) and my backend. There are many samples for iOS, Android, web and react native, where I could find some clues on how to do it, but couldn't manage to get it working in .net core. The best documentation I've found so far is the official Amazon.AppSync API but there you'll find only classes and fields descriptions, not sample code.
I have that Angular AppSync Chat sample app running fine. I did manage to run the React sample app too. Everything goes smoothly with those. However I'm unable to fully understand what's going on only by reading the angular and react sample code, especially because I'm not proficient on those.
Would be great to have a sample code on how to initialise the AmazonAppSyncClient, run some queries, perform some mutations, subscribe/unsubscribe and set background tasks.
AWSSDK.AppSync Is just for managing AppSync, to query GraphQl server provided by AppSync you need GraphQL.Client.
Ok, so here is a little snippet for how to setup client and do a simple query.
Setup client.
Install GraphQL client library, for example from NuGet (works also in Unity),
you need these things:
using GraphQL;
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;
using GraphQL.Client.Abstractions;
Then initialize your client like this:
var client = new GraphQLHttpClient("your_graphql_endpoint_url", new NewtonsoftJsonSerializer());
Optionally, you may want to add authentication or api key headers, here is example of how to add authorization token (notice, there is no "Bearer " word in it, just the token)
client.HttpClient.DefaultRequestHeaders.Add("Authorization", "your_long_token_string");
Now about how to do a simple query. Here is an example for listing items query, create request:
var request = new GraphQLRequest
{
Query = #"
query MyQuery {
listItems {
items {
id
ItemName
}
}
}"
};
Send request:
var request = await _client.SendQueryAsync(request, () => new
{
listItems = new
{
items = new List<Your_Item_Type>()
}
});
Your_Item_type[] items = request.Data.listItems.items.ToArray();
Check the official repository for the client here: https://github.com/graphql-dotnet/graphql-client
I tried to get the content of the user's profile picture and I found out that I had to call the Beta version because the current version gives the following error message:
"code": "GetUserPhoto",
"message": "The operation is not supported."
So, I tried to switch to Beta, and here is the code that I wrote in C# to do it, but it doesn't work:
Microsoft.Graph 1.6.2
List<QueryOption> options = new List<QueryOption>
{
new QueryOption("$api-version", "beta")
};
var pictureStream = await graphClient.Me.Photo.Content.Request(options).GetAsync();
I got the same error message.
I tried the same request in the Graph Explorer. The 1.0 doesn't work, but Beta works.
The api-version query parameter is used by the Azure AD Graph API. This is a different API than Microsoft Graph. There is a lot of functional overlap (Azure AD Graph is slowly being migrated over to Microsoft Graph) but they use entirely different entities and calling conventions.
In order to call the /beta endpoint using the Microsoft Graph .NET Client Library, you need to change the BaseUrl of the client:
graphClient.BaseUrl = "https://graph.microsoft.com/beta";
var pictureStream = await graphClient.Me.Photo.Content.Request().GetAsync();
Some important notes about the /beta endpoint:
It isn't supported and isn't suitable for production. So don't do that. Or at least don't tell anyone and don't call Support if it stops working. ;-)
The .NET Client uses objects constructed off the production metadata. This means that any entities, actions or properties that were added in /beta don't exist in the models shipped with the SDK.
The .NET Client will ignore any values returned by Microsoft Graph that it doesn't expect to see. So if an endpoint returns a property that wasn't included in the production metadata (see #2), it will simply be ignored.
So long as you're only using a /beta to gain functionality but still expecting /v1.0 results, it should work okay. Photos for example only look at Exchange in v1.0 but look in both Exchange and Active Directory but still return the same result. In theory this means you should be able to swap /beta for /v1.0 without a problem.
I think you are still calling V1 endpoint. In fact, the Beta endpoint is not currently supported in the Microsoft Graph .NET Client Library. More info here.
There is an official beta client for Graph API now:
https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet
Is there a way to create a Resource Group with the Azure Management C# API?
Basically this REST API call:
https://msdn.microsoft.com/en-us/library/azure/dn790525.aspx
I found a way to create an Affinity Group by using client.AffinityGroups.Create, but that's the closest thing I've found.
I found the API call was hidden in a library which is only in preview mode at the moment. It's found in the following NuGet package, enable include prerelease in Visual Studio to find it in the NuGet client.
https://www.nuget.org/packages/Microsoft.Azure.Management.Resources/
Then to create a resource group I can use
var credentials = new TokenCloudCredentials("", "");
var client = new Microsoft.Azure.Management.Resources.ResourceManagementClient(credentials);
var result = c.ResourceGroups.CreateOrUpdateAsync("MyResourceGroup", new Microsoft.Azure.Management.Resources.Models.ResourceGroup("West US"), new System.Threading.CancellationToken()).Result;
There is another stack overflow post explaining how to do the authentication:
How to get Tags of Azure ResourceManagementClient object
The following blog post explains how to set up TokenCloudCredentials, required for the authentication part, in more detail, but only for command line apps:
http://www.bradygaster.com/post/using-windows-azure-active-directory-to-authenticate-the-management-libraries
If you want to use something other than a command line app the following can work for authentication:
http://www.dushyantgill.com/blog/2015/05/23/developers-guide-to-auth-with-azure-resource-manager-api/
Go to https://resources.azure.com - the ARMExplorer shows both the REST and the PowerShell commands to create a resource group. All the APIs are REST based. In C#, send a WebClient request.
I have setup up a .NET console application that will do the following:
Access the Google Contacts API for my personal Google Account
Perform basic CRUD (create, read, update, delete) operations to these contacts
I believe executing the CRUD operations will be straight forward using the following documentation:
https://developers.google.com/google-apps/contacts/v3/#about_authorization_protocols
However, my problems are occurring when trying to authenticate my connection using OAuth2.0.
I am using the Google.GData.Contacts .NET NUGET Package using the code from the following example:
https://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/oauth2_sample/oauth2demo.cs?r=1159
OAuth2Parameters parameters = new OAuth2Parameters() {
ClientId = clientId,
ClientSecret = clientSecret,
RedirectUri = redirectUri,
Scope = scopes
};
string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
Console.WriteLine("Authorize URI: " + url);
parameters.AccessCode = Console.ReadLine();
OAuthUtil.GetAccessToken(parameters);
As this code was last updated in 2012, I'm worried it might no longer be relevant for my task.
Major Questions:
I'm not sure exactly what the parameters.AccessCode value is. Where does this value come from?
Based upon my use case am I using the correct OAuth2.0 approach? You can can setup authentication for a Service Account, Web Application, or Native Application. The above code implies Native Application
Is there a better way to handle my task?
The access code should be used only for WebServer Applications.
I'm not sure if your console app will run in an environment where a browser can be launched or not.
If yes (your app is running in a environment where a URL can be launched), use the documentation for Installed Applications.
If browser is not present, you can use the documentation for Applications on limited-input devices.
If the library you're targeting to use (NUGET, whatever) has no support for this flow, don't worry: it's easy to write custom code. You can use any library able to do HTTP/HTTPS requests, like or Windows.Web.Http.HttpClient (Windows 8 and later).
Additionally, you can use contact import services like CloudSponge, which offers a .Net API and support for other contact sources (in case you want expand your address book support in the future).
AccessCode comes from the URL created in that Line above. See here:
string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
url contains a URL now for your browser. Fill it in Chrome/Firefox/etc and confirm the google request to get the AccessCode. It will look like this "4/bAQT1qf66vpkmfU8xDkoVZmedvVoYDH6KovzcHcA5pc" but will change every time you call the URL.
Console.WriteLine("Authorize URI: " + url);
now you can see the url but you might not be able to copy it from your console. But if you get it into your browser, it will result in a google dialog to get your AccessCode.
As of August 15, Amazon made it compulsory to sign all requests made to their Product Advertising API. I thought I had got everything working just fine but when the 15th finally came around, my web application stopped working and pretty much ever since I have been trying to find out how to sign the SOAP requests.
Amazon has an outdated sample code for signing requests that doesn't appear to work here
Basically, I need to know how to add a signature to the my requests using the most current C# SOAP API and .NET 3.5.
I hope I have given enough details, if I haven't please feel free to ask me to elaborate.
Thank You
The_Lorax
UPDATE:
I am using MVC and need to know how to add the Signature to the the ItemLookup or AWSECommerceService object. Is there an attribute that contains the signature value? How does it get attached to the request?
On this page, they say that I must include the Signature and TimeStamp parameters but the intellisense does now show any such attributes.
Check out http://flyingpies.wordpress.com/2009/08/01/17/. It has a walkthrough and a sample visual studio solution using C#, SOAP, WCF on .NET 3.5.
This library automatic sign the requests (Install-Package Nager.AmazonProductAdvertising)
https://www.nuget.org/packages/Nager.AmazonProductAdvertising/
Example:
var authentication = new AmazonAuthentication("accesskey", "secretkey");
var client = new AmazonProductAdvertisingClient(authentication, AmazonEndpoint.US);
var result = await client.SearchItemsAsync("canon eos");