• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

xamarin/google-apis: Google API bindings for Xamarin.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

xamarin/google-apis

开源软件地址(OpenSource Url):

https://github.com/xamarin/google-apis

开源编程语言(OpenSource Language):

C# 100.0%

开源软件介绍(OpenSource Introduction):

Google APIs for Xamarin

Quickly add access to Google's APIs to your Mono for Android app!

To get started with the Google APIs, you'll need to register your app as a web application and obtain your client ID at the Google API Console.

A set of generated APIs are included, but additional or newer versions of the APIs may be available at Google API .NET client WIKI.

Before you can access the APIs, the user will need to login to Google. You'll need to supply your Client ID, the redirect URI you supplied to Google, and the scopes you're requesting. Each API has a set of scopes that will enable you to access certain functionality.

var auth = new Google.Apis.Authentication.OAuth2.GoogleAuthenticator (ClientID,
				new Uri ("http://example.com/callback"),
				Google.Apis.Tasks.v1.TasksService.Scopes.Tasks.GetStringValue());

// When we're authenticated, we'll show the tasks from the default list
Action showTasks = () =>
{
	var service = new Google.Apis.Tasks.v1.TasksService (auth);

	// get the tasks from the default task list
	var tasks = service.Tasks.List("@default").Fetch();
	foreach (var task in tasks.Items)
		Console.WriteLine (task.Title);
};

// We don't want to have to login every time, so we'll use the Xamarin.Auth AccountStore
AccountStore store = AccountStore.Create (this);
Account savedAccount = store.FindAccountsForService ("google").FirstOrDefault();
if (savedAccount != null)
{
	this.auth.Account = savedAccount;
	showTasks();
}
else
{
	this.auth.Completed += (sender, args) =>
	{
		if (args.IsAuthenticated)
		{
			// Save the account for the future
			store.Save (args.Account, "google");
			RunOnUiThread (showTasks);
		}
		else // Authentication failed
			Toast.MakeText (this, "Error logging in", ToastLength.Long).Show();
	};

	Intent authIntent = this.auth.GetUI (this);
	StartActivity (authIntent);
}

Intent loginIntent = auth.GetUI (this);
StartActivity (loginIntent);



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap