Giter VIP home page Giter VIP logo

google-dotnet-samples's Introduction

Hi there ๐Ÿ‘‹

Linda Lawton GitHub stats

Facts:

Fun Facts:

  • ๐Ÿ”ญ Iโ€™m currently working on Google analytics with Gemini AI.
  • ๐ŸŒฑ Iโ€™m currently learning Python, Google Cloud and Machine Learning.
  • ๐Ÿ’ฌ Ask me about Google APIs
  • โšก Fun fact: My first grandchild is due September 2022.

google-dotnet-samples's People

Contributors

ahkim avatar jaider avatar k0t3r avatar lindalawton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-dotnet-samples's Issues

MsBuild and Nuget package restore

Create a dummy project. With all of the packages. Run each class though it to ensure there are no errors in the generation. I will need to be able to delete the packages every time i run to ensure i am running with the same packages that the client library was built from.

restore all the packages.

nuget.exe restore dummySolution.sln

Build the project

D:\MSbuild>C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "D:\Projects\dummySolution\dummySolution.sln" /property:Configuration=Debug

Sample code on azure websites - google authentication

Hi Linda, This is a nice article and very good implementation. Have you ever tried deploying this to any azure websites? I cant get it to work pass this point.

var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, userName
, CancellationToken.None
, credentialPersistanceStore).Result;

and the logs weren't very helpful.

Standardize Readme

Each project should have a readme with the following.

Description

Description of the API it is for.

Setup

    1. Info on how to create the client id
    2. .net version
    3.  Location of the NuGet package needed for this project.

Tutorials

Assuming I have created tutorials to go along with the project which i normally do, links to the tutorials will go here.

Links

  • Links to the documentation needed for the sample project
  • Nuget package
  • oauth
  • api documentation.
  • possibly a link to the stack over flow tag for the api.

Please HelpMe

I need to upload a file to Google Drive to facilitate a project I'm doing University, but I can not do it, because I do not understand the requirement you ask in the following

public static File uploadFile(DriveService _service, string _uploadFile, string _parent)

I already have the authentication and me auntentica well, but the problem I have is "_parent" that should go there? I do not understand that? could you explain me

Google Authentication.

Hi Linda,
Your blog is very good and I will be visiting it more often as I have just started working on Google Analytics.

I am using this code to get authenticated on Google. I am using a console based application written in C#. Everytime I call this, I invoke a browser and I have to hit accept on the google website. I am using the Google.Apis.Auth.OAuth2 library available from Nuget.

The question I have is, how can I make use of the stored token instead of having to invoke the browser for each invocation of the program.

private void Run()
        {
            UserCredential credential;
            using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
            {
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    new[] { DriveService.Scope.Drive, DriveService.Scope.DriveFile, AnalyticsService.Scope.Analytics, AnalyticsService.Scope.AnalyticsReadonly },
                    Environment.UserName, CancellationToken.None, new FileDataStore("OAuthTokens.Store")).Result;
            }
}

Thank You,
Abhi

Facing problem when hosting web application on IIS

Hi,

I am working on C# MVC web application . In this application I am integrating google drive and using Google.Apis (version- 1.19.0.0). For this implementation I have taken the reference from your sample code and have implemented successfully in my application. During testing I have found that it is working fine when I run directly this from visual studio but when I deployed this on IIS (even local IIS) it is not working. After investigation I have found that it is giving problem in authentication and not trigger the authenticate screen with Gmail account. Mainly giving me on this below line :

UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets {ClientId = clientId, ClientSecret = clientSecret} , scopes , userName , CancellationToken.None
, new FileDataStore(folder,true)).Result;

Nothing has happened after this line (no error) . Kindly help me on this . How I can solve this problem? Is there any setting in IIS that I need to set for this ?

Some trouble shooting I already done like :

  1. Given permission to folder (that store the outh response ). Like asp.net users .
  2. Tried with both folder default roaming folder and custom folder (for store the outh response)

Let me know if you want more information from my side.

Best regards,
Sunil Sharma

Error Bad Request [400] using Gmail API

I have this code, using Service Account:

`

            string[] Scopes = {
                Google.Apis.Gmail.v1.GmailService.Scope.MailGoogleCom,
                Google.Apis.Gmail.v1. GmailService.Scope.GmailModify,
                Google.Apis.Gmail.v1.GmailService.Scope.GmailCompose,
                Google.Apis.Gmail.v1.GmailService.Scope.GmailSend };

        var pathSecrets = @".\ContactosProject-dcbe8450d418.json";
        var serviceAccountEmail = "[email protected]";

        var gmailSvc = GmailAPI.ServiceAccountHelper.AuthenticateServiceAccount(serviceAccountEmail, pathSecrets, Scopes);

        string plainText = "To: [email protected]\r\n" +
                           "Subject: subject Test\r\n" +
                           "Content-Type: text/html; charset=us-ascii\r\n\r\n" +
                           "<h1>Body Test </h1>";

        var newMsg = new Google.Apis.Gmail.v1.Data.Message();
        newMsg.Raw = Base64UrlEncode(plainText.ToString());
        gmailSvc.Users.Messages.Send(newMsg, "me").Execute();`

I use your AuthenticateServiceAccount class for samples.

I get the error:

Result StackTrace:
at Google.Apis.Requests.ClientServiceRequest1.<ParseResponse>d__34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Google.Apis.Requests.ClientServiceRequest1.Execute()

Google.GoogleApiException: Google.Apis.Requests.RequestError
Bad Request [400]
Errors [
Message[Bad Request] Location[ - ] Reason[failedPrecondition] Domain[global]
]

The same error for

        Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest request = gmailSvc.Users.Labels.List("me");
        var Labels = request.Execute().Labels;

Any suggestions?

Remove unnecessary files -> .dlls

Add .gitignore

A working example can be found in the Drive project. .gitignore

What it does:
Remove packages and bin directories. This will prevent all of the .dlls from being uploaded with the project.

packages/
Google-Drive-Api-dotnet/bin/

Drawback:
Users will have to run NuGet package to get them on there own. Which probably isn't a bad thing.

Issue:
The only way I have figured out how to do this currently is to delete the directory on my PC then update the project removing the files, add the .gitignore then add the files back on my PC so i can still use the project. There should be a one shot delete directory from the repository but I haven't found it yet.

Automatic Sample generation

I am currently working on an application that automatically generates standardized Sample projects for the Google .net client library.

  1. Reads from the Discovery services API
  2. Uses T4 template files for standardized Generation.
  3. Phase one generates simple console applications.
  4. Samples will be released under the Apache License like the Google .net client library unless someone has a better idea.

I currently have 135 sample projects generated size 85 mb in total. I am generating for all versions of the APIs found in the Discovery services.

My hope is this will give us a way of creating some best practices standards for usage of the Client library. The code should be simple to use and make it easier for new developers to access the Google APIs. Each method supplies a link directly to its documentation on Google developers website, and gives information on the different parameters needed to make the request.

Example

I will upload a single generated example in a branch so that we can do a code review before I upload them all. This will probably be either Google Analytics or Google Drive as i know those APIs the best and we will be able to work out how to show usage of upload and download.

Sample currently under review: Google Analytics v3

Issues

I am unable to programmatic create the packages.config users will have to run the NuGet package manually to get the necessary references to run the application. I have added a link and the command to the README.md for each project directly to the package needed. I was hoping we could have just used NuGet package restore but currently this isn't possible.

I would like to see if i can find a way of validating the public API key, client id, client secret, and service account email addresses for the Authentication methods. Validating Google credentials

Future Plans
I would like to automated it so that the application checks for changes in Discovery services and regenerates a new sample when needed and uploads them directly to GitHub. For this to work the application will need to build the sample as well to insure there are no errors. There is a problem with this due to the in ability to generate the packages.config. Build will have to add the NuGet package we can not rely on NuGet package restore.

Note: Because I am using T4 templates it will be possible to create templates for the other client library's at a later date. This issue will only be related to generation of the .net samples.

Issues with first generated sample upload

Licence file

Licence file in the API version directory appears to have been eaten only a portion if it has been uploaded.

Move files
Move both licence and readme up one directory. There is no reason to have them as part of each version. This will leave room for a read me with maybe some usage examples. It should also fix the garbled directory structure.

description is to long
Some of the description fields are to long and are causing a display issue on GitHub. Visual studio can handle it but it appears that GitHub doesn't like long descriptions. I am going to have to add some returns.

Sheets API V4
Where is the sheet create method?? It is in discovery, it is in the client library. No sample was created for it. Why?

Service accounts have weird scope

https://github.com/LindaLawton/Google-Dotnet-Samples/blob/Genreated-samples1.0/Gmail%20API/v1/ServiceAccount.cs

spacing issue with the helper class also its probably not needed here

https://github.com/LindaLawton/Google-Dotnet-Samples/blob/Genreated-samples1.0/Drive%20API/v3/AboutSample.cs

Hi LindaLawton

I read your Project this is Extremely Good . actually I am New Beginner with Google Calender API. actually I want to Create Event and Get Appointment Using Web Credential . but I have no Idea How to do it. can you help me in figure out it.and How to pass User credential for the invoke Google Calender service Please Help me Asap.

Thanks & Regards
Munesh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.