How to access user data in Azure Mobile App services (.Net backend) - c#

I'm working on an app using Azure's Mobile App services (as opposed to Azure Mobile Services). I've successfully implemented the single sign-on with FB (mentioned here: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-how-to-configure-facebook-authentication-preview/), but now that I can log in I can't figure out how to access the user information on the backend (such as basic user information and access tokens).
Could someone please provide an example or point me to a tutorial explaining how to access this data?

Take a look at the following tutorial blog post: http://blogs.msdn.com/b/carlosfigueira/archive/2013/12/16/enhanced-users-feature-in-azure-mobile-services.aspx - also http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx
This is written a while ago, and uses the NodeJS backend, but you should be able to translate this to .NET as the same basic information exists - you use GetIdentities() to get the facebook token, then use the Facebook REST interface or the SDK (http://facebooksdk.net/) to get the rest of the information you need.
The basic piece of information you need is to use the GetIdentities() call to get your

Related

Accesing LinkedIn API V2 from .NET C#

I am building an application that should work with LinkedIn API V2 to make a data provider that will go through authorization process with OAuth2.0 and that will exchange the code with access token in order to make API calls towards LinkedIn in order to access the specific data from the user.
Does anyone know if there is any up-to-date library for easier implementation of LinkedIn API V2 in order to use it within my .NET Application, it is made with WPF (Windows Presentation Forms)
Basically what I am looking for is something similar to Facebook and Instagram Graph-API, I hope there is or there will be something for LinkedIn, let me know if you have some info!
Thank you!

How can we access specific Google Analytics account data using API and C#?

We are developing an app that intended to access website data of other websites owners who are registered on our app.
What we want that user will login into their gmail account and provide our app access to their google analytics account for their website.
We need complete implementation using c# of google analytics API where we can ask user to give our app access. Any help will be highly appreciated.
You need to use Google Analytics Reporting API. There is quick start guide is available for the Java, Python and PHP. I have created custom reports in PHP.
Use this link: https://developers.google.com/analytics/devguides/reporting/core/v4/
Here you can use REST APIs in your C# application:
https://developers.google.com/analytics/devguides/reporting/core/v4/basics

How to use OneDrive CSharp SDK as a Service or daemon app?

I am coding against the OneDrive C# SDKand I have a few questions.
Question 1.
Does the OneDrive C# SDK use the Microsoft Graph API under the hood?
... If so, how can I use the SDK to pass in my client_Id and client_secret and authenticate as a service or daemon app instead of a traditional OAuth for a user?
I have proofed out the authentication for a service with REST calls but I am trying to proof out if it is still possible to use a C# SDK instead.
Question 2.
I found this article Azure Active Directory Graph Service Tutorial. After following the example I am able to create an HTTP POST call and return an access_token. My question is there a way to use this token in conjunction with the Microsoft Graph CSharp SDK or OneDrive CSharp SDK to serve as the authentication process?
Update:
Okay, I was able to proof out some more and having a working code, but I am now getting an error around {Code: InvalidAuthenticationTokenMessage: Access token validation failure.
I did the exact same call with Postman and was able to get data back with REST calls, is REST the only way to achieve this?
I created a gist for my attempt: Code
Solved
On line 62 in the gist, I was hitting the wrong resource. The correct resource is https://graph.microsoft.com

Connecting to Yammer from Azure Webjob

I am attempting to connect to Yammer using their .NET SDK but I am having a hell of a time managing this... The point of this exercise is to create an application in Azure which periodically - and AUTONOMOUSLY - contacts Yammer and fetches the latest messages from a specific Yammer group.
Does anyone know of the correct way to use the Yammer .NET SDK from, let's say, a console application, which does not rely on a browser (a.k.a. direct user interaction) to successfully connect via OAuth authentication?
What I have tried:
Trying to suss out what to do from the example given on .NET SDK page on developer.yammer.com, you can see under "Standard Process" an example which shows the LaunchSignIn() function with an incorrect signature! The example shows the usage as:
var authResponse = await OAuthUtils.LaunchSignIn(_clientConfig.ClientId, _clientConfig.RedirectUri, ssoEnabled);
whereas the actually signature I get from the dll is:
void OAuthUtils.LaunchSignIn(string clientId, string RedirectUri)
I'll forgive the missing ssoEnabled parameter... but the example claims the function receives a response, from which a Code is then extracted. This is, of course, the piece missing from my attempt to call:
(awaitable) Task<AuthEnvelope> AuthClient.AuthenticateAppAsync(string code)
I have scoured Google for information on the use of the Yammer .NET SDK but have come up empty handed. All manner of examples of connecting to Yammer but none are in any way relevant to the .NET API. The only thing in any way relevant that I have seen is the Yammer .NET API example uploaded, apparently, by the person who developed it, who posted the code on GitHub. I have checked this example but the two parts in it - one for Windows Phone and one for Windows "Modern App" - both rely on a Browser object being available, or something to that effect anyway. There are redirects, I'm supposed to have a RedirectUri for Yammer to direct me... So does this other example - which was the ONLY other example of using the .NET SDK that I could find.
I imagine that the reason the signature is different is because this isn't actually the same function at all. The one I am trying to use is in Yammer.Oss.Api.Utils whereas the example application doesn't even have the letters Utils together other than in the name of the class OAuthUtils... which leads me to believe that it is possibly under Yammer.Oss.Core.WinRT which, as luck would have it, I cannot reference at all... Yammer.Oss.Core only contains Collections, Constants, Extensions and Serialization.
By the way, in the announcement of the .NET SDK (see first link above), the link to documentation for the SDK leads to the Yammer Support page.
Skip the .NET SDK and just do the authorization yourself using the server-side flow. Then make the requests with HttpClient and add the Authorization header. The SDK might be helpful with some Modern Apps but it's overkill for most people. When working with the API manually the worst thing you'll have to deal with is deserializing the JSON responses with JSON.NET, or other JSON library.
You don't say what you are trying to build, but AFAIK WebJobs don't have a UI so you'll need to do the authorization from a console app or website. Then store the resulting OAuth token somewhere that the WebJob can access it. If you have need an OAuth token per user you'll need to store those in a database, but make efforts to protect them because each OAuth token provides access to their Yammer account.

Integrating all the social sites using asp.net

I am developing a website using ASP.Net and I want to integrate Social Network that gives the user to share a page to their Facebook, twitter,Google plus, linked in and other accounts
These sites will use OAuth, which you will need to integrate into your site.
For example, you could create a Facebook Application using the developers section on Facebook and then use the c# Facebook API from your ASP.Net application to authenticate with the application and post content to the users timeline. I implemented something like this recently, it's pretty simple to do.
You won't have a 'universal set of credentials' for all of the social media that you have mentioned, so you would need to manage and perform OAuth for each of the different Media, e.g. As well as post to Facebook, create a tweet for the user as well.
It's certainly possible, there are Social Marketing applications that do something like this, you just need to manage the access to the OAuth partners.
Just remember, never store credentials that the user has entered in your site. They are not managed by your site so you should never attempt to store them or do anything with them, always delegate to the 3rd party site and receive your access token back. That's all your application should be interested in
Have a read up on how OAuth works. Also, visit each sites developer documentation to see how their specific implementation of OAuth works. There are c# client applications for accessing the sites (c# facebook api, c# twitter api etc etc)

Categories