Get Google analytics data using Oauth token? - asp.net

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();

Related

Get list of nest devices with .NET client API

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.

Xamarin Azure Facebook get user info

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.

Retrieve All Users From Auth0

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.

How to post on my facebook page from my website using Facebook App keys created from my facebook account?

Below is the code i am using to achieve this functionality, and i have successfully posted it to my facebook wall from my website but i am not able to post to my facebook page?
How can i get page access token using FaceBookClient() in c# SDK?
var client = new FacebookClient();
dynamic token = client.Get("oauth/access_token", new
{
client_id = ConfigurationManager.AppSettings["FacebookAPI"].ToString(),
client_secret = ConfigurationManager.AppSettings["FacebookAPIKey"].ToString(),
grant_type = "client_credentials"
});
client.AccessToken = token.access_token;
dynamic parameters = new ExpandoObject();
parameters.title = detail.Title;
parameters.message = GetDescription(detail.Description, detail.Content);
parameters.link = "http://test.com/blog" + detail.RelativeLink;//HttpContext.Current.Request.IsLocal ? "http://test.com/blog" + detail.RelativeLink : HttpContext.Current.Request.Url.Authority + "" + detail.RelativeLink;
var result = client.Post(ConfigurationManager.AppSettings["FacebookPageID"].ToString() + "/feed", parameters);
Please read the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed#publish
It's clear that you can't use an App Access Token for posting to a Page, because a Post always needs to be related to a profile.
A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.

Can I use Firebase simple login to access Twitter API?

It's easy to get the simple login working with Twitter, and that's a big bonus, but I was wondering whether it's possible to then take those authentication credentials and post a tweet, get a list of people they're following, generally use the full Twitter 1.1 API. I.e. can I get hold of the access token key and secret?
Thanks,
Dave.
The Firebase Simple Login JavaScript client now returns both the Twitter access token and access token secret in the response payload from Twitter authentication.
You can access each of these via the user object, under the attributes accessToken and accessTokenSecret as shown below:
var firebaseRef = new Firebase('https://<MY-FIREBASE-NAME>.firebaseIO.com');
var authClient = new FirebaseAuthClient(firebaseRef, function(error, user) {
if (user) {
var accessToken = user.accessToken,
accessTokenSecret = user.accessTokenSecret;
}
});
...
// Sample jQuery click event.
$myButton.on('click', function(event) {
authClient.login('twitter');
});

Resources