SlideShare a Scribd company logo
1 of 37
Introduction to the .NET
client library
https://code.google.com/p/google-api-dotnet-client/
Eyal Peled
peleyal@
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET REST
●
Representational State Transfer
●
Client and servers
transfer resource representations
●
The set of verbs in a REST API
is typically limited to “CRUD”
●
See Google API Explorer for links
to all Google API Rest services
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Http Layer
HttpClient
●A simple programming interface to code against -
SendAsync, GetAsync, etc.
●It uses the new Task based asynchronous methods, which
makes writing responsive and performant UI applications
across all platforms a lot simpler.
●Targets Windows 7 and 8, WP, etc. See PCL
●Part of .NET 4.5 (not PCL) and available for .NET 4.0
developers as a PCL (using NuGet)
https://code.google.com/p/google-api-dotnet-client/
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Http Layer
HttpClient
●Message handlers as a key architectural component
●Every request is passed through a chain of handlers
(derive from HttpMessageHandler)
●HttpClientHandler uses
●
System.Net.HttpWebRequest
and
●
System.Net.HttpWebResponse
under the cover, and provides a
great abstraction.
Google APIs .NET Http Layer
ConfigurableMessageHandler The main HTTP logic
IHttpExecuteInterceptor Interceptor before request is made
IHttpUnsuccessfulResponseHandler Handler for abnormal HTTP response
IHttpExceptionHandler Handler for an exception during a request
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Http Layer
ws
https://code.google.com/p/google-api-dotnet-client/
ConfigurableHttpClient
●
Inherits from HttpClient
●
Contains the handler
Google APIs .NET Http Layer
https://code.google.com/p/google-api-dotnet-client/
HttpClientFactory
• Constructs a new HttpClient
• Great for mocking using
CreateHandler
(By default creates HttpClientHandler)
Google APIs .NET Http Layer
https://code.google.com/p/google-api-dotnet-client/
BackOffHandler
●
Implements exception and unsuccessful
response handlers
●
Contains a BackOff logic
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Client Service
https://code.google.com/p/google-api-dotnet-client/
IClientService
●
Serialization
●
GZip support
●
Authenticator
(Will be removed after a new Auth library will
be created)
Google APIs .NET Client Service
https://code.google.com/p/google-api-dotnet-client/
BaseClientService
●
Thread-safe uses Initializer
●
Expoenential back-off policy
●
Api Key
●
GZip Enabled
●
Client Factory
Google APIs .NET Client Service
Generated services inherit from BaseClientSerivce
●
They implement resource related properties
• They contain resources and methods based on Discovery
Follow DriveService implementation in the next slide...
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Client Service
public class DriveService : Google.Apis.Services.BaseClientService
{
public DriveService(Google.Apis.Services.BaseClientService.Initializer initializer)
: base(initializer)
{
about = new AboutResource(this);
files = new FilesResource(this);
...
}
public override string Name { get { return "drive"; } }
public override string BaseUri { get { return "https://www.googleapis.com/drive/v2/"; } }
public override string BasePath { get { return "drive/v2/"; } }
public enum Scopes
{
/// <summary>View and manage the files and documents in your Google Drive</summary>
[Google.Apis.Util.StringValueAttribute("https://www.googleapis.com/auth/drive")]
Drive,
/// <summary>View and manage its own configuration data in your Google Drive</summary>
[Google.Apis.Util.StringValueAttribute("https://www.googleapis.com/auth/drive.appdata")]
DriveAppdata,/// <summary>View your Google Drive apps</summary>
…
}
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Service Request
https://code.google.com/p/google-api-dotnet-client/
ClientServiceRequest
●
ETag support
●
based TPL
Execute  ExecuteAsync
ExecuteAsStream 
ExecuteAsStreamAsync
Google APIs .NET Service Request
Generated requests inherit from ClientServiceRequest
● They Implement the concrete HttpMethod, RestPath, etc.
● They are executed by calling to Execute (or ExecuteAsync)
Follow GetRequest (File) implementation in the next slide...
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Service Request
public class GetRequest : DriveBaseServiceRequest<Google.Apis.Drive.v2.Data.File>
{
public GetRequest(Google.Apis.Services.IClientService service, string fileId)
: base(service)
{
FileId = fileId;
InitParameters();
}
[Google.Apis.Util.RequestParameterAttribute("fileId", Google.Apis.Util.RequestParameterType.Path)]
public virtual string FileId { get; private set; }
[Google.Apis.Util.RequestParameterAttribute("projection",
Google.Apis.Util.RequestParameterType.Query)]
public virtual System.Nullable<ProjectionEnum> Projection { get; set; }
public override string MethodName { get { return "get"; } }
public override string HttpMethod { get { return "GET"; } }
public override string RestPath { get { return "files/{fileId}"; } }
…
}
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Media
Resumable Media Upload
https://code.google.com/p/google-api-dotnet-client/
The protocol
●
Recovery server errors
●
Chunk size
●
Progress changed event
●
Upload
●
UploadAsync
Google APIs .NET Media
Media Downloader
https://code.google.com/p/google-api-dotnet-client/
●
Chunk size
●
ProgressChanged event
●
Download
●
DownloadAsync
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET OAuth2
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET OAuth2
https://code.google.com/p/google-api-dotnet-client/
Google OAuth2 documentation
Google API Console
Support installed and web applications
Support service account
Current implementation
●IAuthenticator to apply authorization header to a request
●Usage of DotNetOpenAuth
●Implementation is in Google.Apis.Authentication.OAuth2
Google APIs .NET OAuth2
https://code.google.com/p/google-api-dotnet-client/
Roadmap
●
Remove DotNetOpenAuth
●
Create a Google.Apis.Auth PCL
●
Create concrete implementation for

Google.Apis.Auth.DotNet4 (installed applications)

Google.Apis.Auth.Mvc4 (web applications)

Google.Apis.Auth.WP (Windows Phone)

Google.Apis.Auth.WinRT (Windows 8 applications)
The main reason for creating a specific assembly for a
platform is based on the way we read the authorization code.
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET PCL
Portable Class Library
Current status
●
Google.Apis is PCL
●
The generated APIs are PCLs as well
Roadmap
●
Create a Google.Apis.Auth PCL library (see OAuth slides)
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET 3rd parties
NuGet packages:
•
Newtonsoft.Json 5.0.5
Json is the client's default data format
•
Microsoft.Net.Http 2.1.10
We use HttpClient as our transport layer.
•
Microsoft.Bcl.Async 1.10.16
Although we target .NET 4.0 we use async-await
•
Zlib.Portable 1.9.2
While GZip is enabled, we use this library to encode messages
•
log4net
The library's logging framework
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Discovery
●
Each Google API service exposes a discovery doc using the
json format (e.g.
https://www.googleapis.com/discovery/v1/apis/drive/v2/rest)
●
The service generator generates a service, resources,
models and requests by this doc
●
Similar to wsdl
●
Read more about Discovery API here
https://code.google.com/p/google-api-dotnet-client/
Agenda
Rest
Http Layer
Client Service
Service Request
Media
OAuth2
PCL
3rd parties
Discovery
Code Generator
https://code.google.com/p/google-api-dotnet-client/
Google APIs .NET Code Generator
https://code.google.com/p/google-api-dotnet-client/
●
From 1.5.0-beta we use Google APIs client generator (which
is available here)
●
The .NET specific templates for 1.5.0-beta are available
here.
●
The decision to move to Google APIs client generator was
based on the following:

Share logic with other Google APIs client libraries

It is easier to use Django templates

It reduces library code significantly

One step forward supporting End Points
Resources
•
code.google.com - WIKI
•
Google API .NET Announcements blog
•
StackOverflow google-api-dotnet-client tag
•
Google Group
•
Google API Explorer
•
Google API Console
https://code.google.com/p/google-api-dotnet-client/
Questions?
https://code.google.com/p/google-api-dotnet-client/

More Related Content

Recently uploaded

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Introduction to the Google APIs Client Library for .NET

  • 1. Introduction to the .NET client library https://code.google.com/p/google-api-dotnet-client/ Eyal Peled peleyal@
  • 2. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 3. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 4. Google APIs .NET REST ● Representational State Transfer ● Client and servers transfer resource representations ● The set of verbs in a REST API is typically limited to “CRUD” ● See Google API Explorer for links to all Google API Rest services https://code.google.com/p/google-api-dotnet-client/
  • 5. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 6. Google APIs .NET Http Layer HttpClient ●A simple programming interface to code against - SendAsync, GetAsync, etc. ●It uses the new Task based asynchronous methods, which makes writing responsive and performant UI applications across all platforms a lot simpler. ●Targets Windows 7 and 8, WP, etc. See PCL ●Part of .NET 4.5 (not PCL) and available for .NET 4.0 developers as a PCL (using NuGet) https://code.google.com/p/google-api-dotnet-client/
  • 7. https://code.google.com/p/google-api-dotnet-client/ Google APIs .NET Http Layer HttpClient ●Message handlers as a key architectural component ●Every request is passed through a chain of handlers (derive from HttpMessageHandler) ●HttpClientHandler uses ● System.Net.HttpWebRequest and ● System.Net.HttpWebResponse under the cover, and provides a great abstraction.
  • 8. Google APIs .NET Http Layer ConfigurableMessageHandler The main HTTP logic IHttpExecuteInterceptor Interceptor before request is made IHttpUnsuccessfulResponseHandler Handler for abnormal HTTP response IHttpExceptionHandler Handler for an exception during a request https://code.google.com/p/google-api-dotnet-client/
  • 9. Google APIs .NET Http Layer ws https://code.google.com/p/google-api-dotnet-client/ ConfigurableHttpClient ● Inherits from HttpClient ● Contains the handler
  • 10. Google APIs .NET Http Layer https://code.google.com/p/google-api-dotnet-client/ HttpClientFactory • Constructs a new HttpClient • Great for mocking using CreateHandler (By default creates HttpClientHandler)
  • 11. Google APIs .NET Http Layer https://code.google.com/p/google-api-dotnet-client/ BackOffHandler ● Implements exception and unsuccessful response handlers ● Contains a BackOff logic
  • 12. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 13. Google APIs .NET Client Service https://code.google.com/p/google-api-dotnet-client/ IClientService ● Serialization ● GZip support ● Authenticator (Will be removed after a new Auth library will be created)
  • 14. Google APIs .NET Client Service https://code.google.com/p/google-api-dotnet-client/ BaseClientService ● Thread-safe uses Initializer ● Expoenential back-off policy ● Api Key ● GZip Enabled ● Client Factory
  • 15. Google APIs .NET Client Service Generated services inherit from BaseClientSerivce ● They implement resource related properties • They contain resources and methods based on Discovery Follow DriveService implementation in the next slide... https://code.google.com/p/google-api-dotnet-client/
  • 16. Google APIs .NET Client Service public class DriveService : Google.Apis.Services.BaseClientService { public DriveService(Google.Apis.Services.BaseClientService.Initializer initializer) : base(initializer) { about = new AboutResource(this); files = new FilesResource(this); ... } public override string Name { get { return "drive"; } } public override string BaseUri { get { return "https://www.googleapis.com/drive/v2/"; } } public override string BasePath { get { return "drive/v2/"; } } public enum Scopes { /// <summary>View and manage the files and documents in your Google Drive</summary> [Google.Apis.Util.StringValueAttribute("https://www.googleapis.com/auth/drive")] Drive, /// <summary>View and manage its own configuration data in your Google Drive</summary> [Google.Apis.Util.StringValueAttribute("https://www.googleapis.com/auth/drive.appdata")] DriveAppdata,/// <summary>View your Google Drive apps</summary> … } https://code.google.com/p/google-api-dotnet-client/
  • 17. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 18. Google APIs .NET Service Request https://code.google.com/p/google-api-dotnet-client/ ClientServiceRequest ● ETag support ● based TPL Execute ExecuteAsync ExecuteAsStream ExecuteAsStreamAsync
  • 19. Google APIs .NET Service Request Generated requests inherit from ClientServiceRequest ● They Implement the concrete HttpMethod, RestPath, etc. ● They are executed by calling to Execute (or ExecuteAsync) Follow GetRequest (File) implementation in the next slide... https://code.google.com/p/google-api-dotnet-client/
  • 20. Google APIs .NET Service Request public class GetRequest : DriveBaseServiceRequest<Google.Apis.Drive.v2.Data.File> { public GetRequest(Google.Apis.Services.IClientService service, string fileId) : base(service) { FileId = fileId; InitParameters(); } [Google.Apis.Util.RequestParameterAttribute("fileId", Google.Apis.Util.RequestParameterType.Path)] public virtual string FileId { get; private set; } [Google.Apis.Util.RequestParameterAttribute("projection", Google.Apis.Util.RequestParameterType.Query)] public virtual System.Nullable<ProjectionEnum> Projection { get; set; } public override string MethodName { get { return "get"; } } public override string HttpMethod { get { return "GET"; } } public override string RestPath { get { return "files/{fileId}"; } } … } https://code.google.com/p/google-api-dotnet-client/
  • 21. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 22. Google APIs .NET Media Resumable Media Upload https://code.google.com/p/google-api-dotnet-client/ The protocol ● Recovery server errors ● Chunk size ● Progress changed event ● Upload ● UploadAsync
  • 23. Google APIs .NET Media Media Downloader https://code.google.com/p/google-api-dotnet-client/ ● Chunk size ● ProgressChanged event ● Download ● DownloadAsync
  • 24. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 25. Google APIs .NET OAuth2 https://code.google.com/p/google-api-dotnet-client/
  • 26. Google APIs .NET OAuth2 https://code.google.com/p/google-api-dotnet-client/ Google OAuth2 documentation Google API Console Support installed and web applications Support service account Current implementation ●IAuthenticator to apply authorization header to a request ●Usage of DotNetOpenAuth ●Implementation is in Google.Apis.Authentication.OAuth2
  • 27. Google APIs .NET OAuth2 https://code.google.com/p/google-api-dotnet-client/ Roadmap ● Remove DotNetOpenAuth ● Create a Google.Apis.Auth PCL ● Create concrete implementation for  Google.Apis.Auth.DotNet4 (installed applications)  Google.Apis.Auth.Mvc4 (web applications)  Google.Apis.Auth.WP (Windows Phone)  Google.Apis.Auth.WinRT (Windows 8 applications) The main reason for creating a specific assembly for a platform is based on the way we read the authorization code.
  • 28. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 29. Google APIs .NET PCL Portable Class Library Current status ● Google.Apis is PCL ● The generated APIs are PCLs as well Roadmap ● Create a Google.Apis.Auth PCL library (see OAuth slides) https://code.google.com/p/google-api-dotnet-client/
  • 30. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 31. Google APIs .NET 3rd parties NuGet packages: • Newtonsoft.Json 5.0.5 Json is the client's default data format • Microsoft.Net.Http 2.1.10 We use HttpClient as our transport layer. • Microsoft.Bcl.Async 1.10.16 Although we target .NET 4.0 we use async-await • Zlib.Portable 1.9.2 While GZip is enabled, we use this library to encode messages • log4net The library's logging framework https://code.google.com/p/google-api-dotnet-client/
  • 32. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 33. Google APIs .NET Discovery ● Each Google API service exposes a discovery doc using the json format (e.g. https://www.googleapis.com/discovery/v1/apis/drive/v2/rest) ● The service generator generates a service, resources, models and requests by this doc ● Similar to wsdl ● Read more about Discovery API here https://code.google.com/p/google-api-dotnet-client/
  • 34. Agenda Rest Http Layer Client Service Service Request Media OAuth2 PCL 3rd parties Discovery Code Generator https://code.google.com/p/google-api-dotnet-client/
  • 35. Google APIs .NET Code Generator https://code.google.com/p/google-api-dotnet-client/ ● From 1.5.0-beta we use Google APIs client generator (which is available here) ● The .NET specific templates for 1.5.0-beta are available here. ● The decision to move to Google APIs client generator was based on the following:  Share logic with other Google APIs client libraries  It is easier to use Django templates  It reduces library code significantly  One step forward supporting End Points
  • 36. Resources • code.google.com - WIKI • Google API .NET Announcements blog • StackOverflow google-api-dotnet-client tag • Google Group • Google API Explorer • Google API Console https://code.google.com/p/google-api-dotnet-client/

Editor's Notes

  1. In the traditional client-server authentication model, the client requests an access-restricted resource (protected resource) on the server by authenticating with the server using the resource owner&apos;s credentials. OLD In order to provide third-party applications access to restricted resources, the resource owner shares its credentials with the third party NEW resource owner - An entity capable of granting access to a protected resource. When the resource owner is a person, it is referred to as an end-user. resource server (GOOGLE) - The server hosting the protected resources, capable of accepting and responding to protected resource requests using access tokens. client - An application making protected resource requests on behalf of the resource owner and with its authorization. authorization server (GOOGLE) - The server issuing access tokens to the client after successfully authenticating the resource owner and obtaining authorization.