How to start with the Google API for Gmail? - c#

I want to receive mails from Gmail in my .NET project with Visual Studio 2022.
I've installed all required NuGet Packages, and now I'm searching for a detailed description of this API.
Which classes and methods are available?
I found something at developers.google.com.
But I miss an overview of the classes and methods.
Or what does the API do?
Right now, I'm able to forward the user of my app to allow me the access to Gmail. I receive the "code", but I have to transform it into a "token2".
Do I have to send a HTTP by myself? Why can I not find a .Net function to do that for me?
Sorry for asking, but I'm searching since two hours for the answer...

Gmail API + Google .net client library Nuget Gmail package.
I've installed all required NuGet Packages, and now I'm searching for a detailed description of this API.
A detailed description of the Gmail api and all its methods can be found on Gmail API documentation page. The documentation for the API lists all the methods that can be used and their required parameters and the responses.
As for the NuGet package for Google.Apis.Gmail.v1 there is no documentation for each of the methods related to each of the Google APIs. This library is generated from the discovery doc so there will be a method in the library for each of the methods listed in the Gmail API documentation. It is "assumed" that by consulting the Gmail API documentations you can "Determine" what method in the library you would need to use.
There is an extremally out of date documentation page for API Client Libraries
.NET
which only goes into some detail of the overall usage of the library it self. It does not tell you how to use every method in every api that it supports.
If you can not figure it out by looking at the documentation as mentioned above then, Your best bet would be to check the assembly directly in visual studio this is something that I am able to do in Rider I would be surprised if Visual studio can not do something similar.
If you have a specific question regarding one of the methods and how to use it in the library please open a new question I would be happy to help.
API vs Client library
what does the API do?
The API gives you access to Gmail api. The Gmail NuGet package gives you access to the Gmail api.
Right now, I'm able to forward the user of my app to allow me the access to Gmail. I receive the "code", but I have to transform it into a "token2".
Depending upon which type of application the library should be handling all the authorization for you. You shouldn't need to worry about the authorization code. Let the library do it for you. Please consult Authorization overview
Do I have to send a HTTP by myself? Why can I not find a .Net function to do that for me?
The library will do all this for you.
var results = service.Users.Labels.List("me").Execute
Will return that response to you.
Links
I think you should start with a few simple examples in order to understand how the Google .NET client library helps you interact with the Gmail api.
Gmail quickstart
How to Access Gmail with C# .net

Related

Guidance for creating client package for my api/webapi

I've tried, but I couldn't find any info about it.
Let's say that I have some webapis for my company that other devs (or qa) are going to use in theirs applications, and for easier use of my apis I'd like to create a library with client so that I can control how other devs are communicating with my api. So basically they can just install this package, add webapi url to configuration, inject necessary dependencies and use it. Is there any pattern, guidance etc. for creating such packages with client? I'm not talking about good practices how to create web api, rest api etc, but just this specific client package.
I've tried googling some tips or guidance about this (or maybe just generic instructions), but all I could find is how to create REST API...
You can use NSwag. With NSwag you can:
Generate Open API/Swagger specification from your Web API controllers. It is just a JSON document describing you API
Include an Html/JavaScript front end in your Web API application where users can see your API and invoke it.
Generate C# clients to invoke your web API.
Useful links:
https://github.com/RicoSuter/NSwag
https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-nswag?view=aspnetcore-7.0&tabs=visual-studio

how to authenticate http requests with Google generated id-token in .net web api back-end?

I have a mobile App in Android that successfully authenticated with Google api returning id-token and also profile information. Now I need to integrate it with my login and registration which I use .net web api as backend. I found google explaind article but not with c# and nuget library and microsoft docs is little difficult to follow. It will be better if i can integrate it with Identity that visual studio provides when creating new project with user authentication generated.
thanks in advance
I resolved my confusion next day after little digging and trying>
Ok first there are two ways of authenticating with third party which i was mixing them and I got confused.
First one in which your application is web or mobile but with web view.
Second way (that I'am using) in which native android activity handle going to google api, so the resulted id-token I manually send it to my api and use this code in c# to verify, requires Google.Apis.Auth library from nuget
var Payload = await GoogleJsonWebSignature.ValidateAsync(idtoken);
See image of steps need to follow in the second way
For more info:
https://youtu.be/zZt8SFivjps
https://developers.google.com/identity/sign-in/android/start-integrating
https://developers.google.com/identity/sign-in/web/backend-auth

How do I determine if a PayPal account is verified using the new .NET REST Libraries

So I installed PayPal.net SDK 1.7.0 in Visual Studio 2010 using the Nuget package. With all my readings this is the 'latest and greatest' and promises to be the most forward compatible library there is from PayPal.
I am having no problem testing the Payout functionality, works nicely.
However, before I do a Payout, I would like to determine if the PayPal user is Verified (address, or bank account), before allowing the Payout. The only documentation I can find that describes what I need here is only available in a soon-to-be-deprecated library called 'Adaptive Accounts'.
https://github.com/paypal/adaptiveaccounts-sdk-dotnet
You go right to the GitHub link, and it even recommends NOT to use it. So, how exactly do I achieve this functionality of pre-verification before issuing a Payout?
This Classic SDK is not actively supported and will be deprecated in
the future. For full support on new integrations, please use the
PayPal .NET SDK
So do I use it or is this functionality supported in the new libraries I have installed, but just can`t find documentation on?
Our REST API library doesn't have any support for AdaptiveAccounts as of this moment.
If you would like to use Adaptive Accounts API, you will need to use Classic API integration. The specific API you should be using is called GetVerifiedStatus API.
https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-accounts/GetVerifiedStatus_API_Operation/
If you are looking for a SDK for it, here is the newest SDK available for AdaptiveAccounts: https://www.nuget.org/packages/PayPalAdaptiveAccountsSDK/
This will not be depreciated, at least not anytime soon until REST API supported AdaptiveAccounts API.

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.

Need google chat API in C#

am new to C#. I am looking for API which provides google chat features.
Can anyone share the API url and sample code would be more helpful.
Thanks.
You should be able to use any XMPP library. There are a bunch out there for .net, one I've dabbled in can be found here: http://www.ag-software.de/agsxmpp-sdk/
Google found this article that may give some good examples.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=346
And from http://code.google.com/apis/talk/open_communications.html#developer
You need to know the following: The
service is hosted at talk.google.com
on port 5222 TLS is required The only
supported authentication mechanism is
SASL PLAIN

Categories