How do I get Google Calendar feed from user's access token? - c#

Using OAuth I do get access token from Google. The sample that comes with Google and even this one:
http://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples
show how to use Tasks API. However, I want to use Calendar API. I want to get access to user's calendar. Can anybody tell me how do I do that?

Take a look at the samples:
Getting Started with the .NET Client Library
On the right side of the page linked above there is a screen shot showing the sample projects contained in the Google Data API solution. They proofed to be very helpful (I used them to start my own Google Calendar application).
I recommend keeping both your own solution and the sample solution open. This way you can switch between the examples and your own implementation.
I also recommend to use the NuGet packages:
Google.GData.AccessControl
Google.GData.Calendar
Google.GData.Client
Google.GData.Extensions
and more ...
This way you easily stay up to date.
Sample to get the users calendars:
public void LoadCalendars()
{
// Prepare service
CalendarService service = new CalendarService("Your app name");
service.setUserCredentials("username", "password");
CalendarQuery query = new CalendarQuery();
query.Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed calendarFeed = (CalendarFeed)service.Query(query);
Console.WriteLine("Your calendars:\n");
foreach(CalendarEntry entry in calendarFeed.Entries)
{
Console.WriteLine(entry.Title.Text + "\n");
}
}

Related

How to Update Account in StripeApi using C#?

I am trying to update Account in Stripe Api using Stripe.netlibrary ,using StripeAccountService and storing it in StripeAccountclass which i made by myself to store the result returned by API :
var accountService = new StripeAccountService("secretKey in string");
StripeRequestOptions option = new StripeRequestOptions();
option.StripeConnectAccountId = "AccountId to update";
StripeAccount x = accountService.Get(option);
x.Email = "Local#local.com";
//Then i do not know how to save changes back to api now.
But StripeAccountService class has no Update method define. How I can perform update on the Account.
I am using this library. Stripe api does have an update method too here.
Stripe.net does not support managed accounts: "Managed Accounts are a valuable service as well, but they are not available in Stripe.net yet." https://github.com/jaymedavis/stripe.net#stripe-connect
Stripe.net doesnot support Managed account but it can be done using following approach it is for update account.
I won't be able to give code but can provide the correct approach, it is tested.
https://api.stripe.com/v1/account
is the Url for updating stripe account.
Now you need to add two header and a body you can try WebRequest or httpclient class.
The reason i am unable to provide code because i did not do any research in adding multiple headers and a body.
so it would look something like this
Header
Property value
Authorization bearer "SecretKey"
Stripe-Account "acct_16uR8kKN01245679"
Body
Property value
email "test#test.com"
support_phone "555-867-5309"
You can see complete property list here. i picked few for demonstration purpose only.
Then save the response in any variable and it is done.

Skybrud social Log in via Facebook?

I'm usinng skybrud social to allow users to log into my site via Facebook, but am having a problem.
For some reason, the response never contains anything other than the Name and Id of the user... everything else is null.
var url = client.GetAuthorizationUrl(state, "public_profile", "email");
var service = FacebookService.CreateFromAccessToken(userAccessToken);
FacebookMeResponse user = service.Methods.Me();
Has anyone experienced this before? What could be the problem?
Facebook has multiple versions of their Graph API. In the most recent version (2.4), less fields are returned by default, and you instead have to tell the API to return the fields that you need. What version of the API you're using depends on the time you registered your app with Facebook.
Based on your code, it seems that you're using an older version of Skybrud.Social. If you update to the most recent version (0.9.4.1), you can do something like this:
// Declare the options for the call to the API
FacebookGetUserOptions options = new FacebookGetUserOptions("me") {
Fields = "name,email,gender"
};
// Make the call to the API
FacebookUserResponse response = service.Users.GetUser(options);
Hope this answers your questions ;)

Quickbooks Online integration c#

My company uses QuickBooks Online, and I would like to write some c# scripts that retrieve very basic information like a list of customers and list of invoices from the QuickBooks Online subscription.
I would also like to submit invoices and payments.
I have created a QuickBooks IPP account (at developer.intuit.com).
I am able to authenticate myself (OAuth) just fine. My questions are:
1) Do I need to authenticate myself every time I wish to connect to QBO IPP (to retrieve a list of customers, submit an invoice, etc.)? Or can my app authenticate itself once & stay 'connected' for months?
2) Is there any sample code to do basic things such as obtain a list of customers, submit an invoice, etc.? I downloaded the sample MVC app from this link
And it was quite helpful - but when I try to get some of the code to work, I just get errors - which leads me to my first question - can I authenticate myself ONCE and use those tokens (appToken, and appTokenSecret) many times in order to perform simple tasks (obtain customer list), or do I have to authenticate myself every time?
Thank you.
Re - 1) Do I need to authenticate myself every time I wish to connect to QBO IPP (to retrieve a list of customers, submit an invoice, etc.)? Or can my app authenticate itself once & stay 'connected' for months?
Please find below steps to get OAuth tokens using which you can make API call against your QBO account. If you create an app in appcenter, you'll get consumerKey and consumerSecret. https://developer.intuit.com/Application/Create/IA
Using the above two tokens, you can generate accessToken and accessSecret from the OAuthPlayground. https://appcenter.intuit.com/Playground/OAuth/IA PN - After completing C2QB(OAuth) flow, you should use 'App Menu API Test.' option which will show you accessToken and accessSecret.
These tokens are valid for 180 days (at max). When these tokens are more than 150 days old (and <180 days), you can make Reconnect API call to revalidate those again.
Ref https://developer.intuit.com/docs/0050_quickbooks_api/0020_authentication_and_authorization/oauth_management_api#Reconnect
So you can always persist these tokens and reuse it.
To let end users connect their QB data with you SaaS app, you need to implement a wizard called 'Connect to Quickbook'. Using 3-legged Oauth your app will be able to capture the acessToken and acessSecret corresponding to the end-user's qbo account.
Ref - https://developer.intuit.com/docs/0100_accounting/0060_authentication_and_authorization/connect_from_within_your_app#7._Add_the_Connect_to_QuickBooks_button
Re - 2) Is there any sample code to do basic things such as obtain a list of customers, submit an invoice, etc.?
Please refer - https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0150_ipp_.net_devkit_3.0/0002_synchronous_calls#/Data_Services_API
and how to add invoice or sales receipt quickbooks rest api v3.0
This is a sample code to get the Quickbooks data using c#.
You can use OAuth play ground(https://developer.intuit.com/app/developer/playground) to get the access token, realm Id.
Base url is https://sandbox-quickbooks.api.intuit.com/v3/company/realmId/query?minorversion={{minorversion}}.
In here I used 55 as minor version.
using Intuit.Ipp.Core;
using Intuit.Ipp.Data;
using Intuit.Ipp.QueryFilter;
using Intuit.Ipp.Security;
using System;
using System.Collections.Generic;
using System.Linq;
namespace InvoiceTable
{
class Program
{
static void Main(string[] args)
{
try
{
//List<Invoice> InvoiceList = new List<Invoice>();
OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_Token);
ServiceContext serviceContext = new ServiceContext(realm Id, IntuitServicesType.QBO, oauthValidator);
serviceContext.IppConfiguration.MinorVersion.Qbo = "minorversion";
serviceContext.IppConfiguration.BaseUrl.Qbo = Base URL;
var querySvc = new QueryService<Invoice>(serviceContext);
var InvoiceList = querySvc.ExecuteIdsQuery("Select Balance From Invoice").ToList();
}
catch (Exception ex)
{
throw;
}
}
}
}
IppDotNetSdkForQuickBooksApiV3 version 10.0.0 is the package that you have to install.

c# program to call Google+ API and Custom Search API from Google

Can you please tell me via a code sample how I can write a C# program that will call
the Google+ API and Custom Search API of Google.
I know there is a brief description of it on :::::
URL:https://developers.google.com/+/api/
URL:https://developers.google.com/custom-search/v1/using_rest
URL:http://code.google.com/p/google-api-dotnet-client/wiki/OAuth2
But the process mentioned in the links in doing the above as given in the documentation is
not very clear.
Is there a simple illustration through C# code that I can use to call Google+ API and Custom
Search API?
The Google API Dotnet Client project contains .NET wrappers form most of Google's APIs, including Google+.
They do have several examples but not for all of their APIs, yet.
A Google+ example from their page to query for public activities is:
CommandLine.EnableExceptionHandling();
CommandLine.DisplayGoogleSampleHeader("PlusService API");
// Create the service.
var objService= new PlusService();
objService.Key = ""; //put in user key.
var acts = objService.Activities.Search();
acts.Query = "super cool";
acts.MaxResults = 10;
var searchResults = acts.Fetch();
if (searchResults.Items != null)
{
foreach (Activity feed in searchResults.Items)
{
//extract any property of uer interest
CommandLine.WriteResult(feed.Title, feed.Actor);
}
}

Simple C# Evernote API OAuth example or guide?

Anybody know where I can find a simple example C# code example? Apparently really tough to find.
I'm just starting out, got my Developer key.
Initial (really noob question/presumption) - -Can (should/must) my solution be a web service client? No new libraries I need to install in .Net right?
Basically, as a test, I want to be able to securely present a single note from a private notebook in html similar to what the Everfort export in html looks like on a outside WebSite.
Many Thanks in Advance!
You should start by downloading our API ZIP from http://www.evernote.com/about/developer/api/. You'll find C# client sample code in /sample/csharp. This sample code demonstrates using the Evernote API from a desktop application that authenticates using username and password.
I am not sure if you ever got this working, but I was playing around with Evernote, OpenAuth and C# this morning and managed to get it all working. I have put together a blog post / library explaining the experience and outlining how to do it with MVC here - http://www.shaunmccarthy.com/evernote-oauth-csharp/ - it uses the AsyncOAuth library: https://github.com/neuecc/AsyncOAuth
I wrote a wrapper around AsyncOAuth that you might find useful here: https://github.com/shaunmccarthy/AsyncOAuth.Evernote.Simple
One prickly thing to be aware of - the Evernote Endpoints (/oauth and /OAuth.action) are case sensitive
// Download the library from https://github.com/shaunmccarthy/AsyncOAuth.Evernote.Simple
// Configure the Authorizer with the URL of the Evernote service,
// your key, and your secret.
var EvernoteAuthorizer = new EvernoteAuthorizer(
"https://sandbox.evernote.com",
"slyrp-1234", // Not my real id / secret :)
"7acafe123456badb123");
// First of all, get a request token from Evernote - this causes a
// webrequest from your server to Evernote.
// The callBackUrl is the URL you want the user to return to once
// they validate the app
var requestToken = EvernoteAuthorizer.GetRequestToken(callBackUrl);
// Persist this token, as we are going to redirect the user to
// Evernote to Authorize this app
Session["RequestToken"] = requestToken;
// Generate the Evernote URL that we will redirect the user to in
// order to
var callForwardUrl = EvernoteAuthorizer.BuildAuthorizeUrl(requestToken);
// Redirect the user (e.g. MVC)
return Redirect(callForwardUrl);
// ... Once the user authroizes the app, they get redirected to callBackUrl
// where we parse the request parameter oauth_validator and finally get
// our credentials
// null = they didn't authorize us
var credentials = EvernoteAuthorizer.ParseAccessToken(
Request.QueryString["oauth_verifier"],
Session["RequestToken"] as RequestToken);
// Example of how to use the credential with Evernote SDK
var noteStoreUrl = EvernoteCredentials.NotebookUrl;
var noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
var noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
var noteStore = new NoteStore.Client(noteStoreProtocol);
List<Notebook> notebooks = client.listNotebooks(EvernoteCredentials.AuthToken);
http://weblogs.asp.net/psteele/archive/2010/08/06/edamlibrary-evernote-library-for-c.aspx might help. As the author states it just bundles some and fixes some. Haven't tried it myself but thought I'd mention for a possibly easier way to get started. Possibly.
This might help too...found it using the Way Back Machine since the original blog site was offline.
https://www.evernote.com/pub/bluecockatoo/Evernote_API#b=bb2451c9-b5ff-49bb-9686-2144d984c6ba&n=c30bc4eb-cca4-4a36-ad44-1e255eeb26dd
The original blog post: http://web.archive.org/web/20090203134615/http://macrolinz.com/macrolinz/index.php/2008/12/
Scroll down and find the post from December 26 - "Get it while it's hot..."

Categories