Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 09, 2020 [SAoC] “D Language Client Libraries for Google APIs” project thread | ||||
---|---|---|---|---|
| ||||
Hi all, I am Robert and during this year’s edition of SAoC I will be working on the “D Language Client Libraries for Google APIs” project. This thread will be used to post further updates. Google APIs is a set of application programming interfaces (APIs) developed by Google which allow communication with Google Services and their integration to other services. Examples of these include GDrive, Calendar, Search or Gmail. Third-party apps can use these APIs to take advantage of or extend the functionality of the existing services. At the moment, there is no client library for D Programming Language which can allow D developers to use various Google APIs. The goal of this project is to implement this library. Milestones for this project: Milestone 1 – Familiarize with dlang-requests, dub and OAuth 2.0 - implement small app using dlang-requests that interacts with weather api - implement small app using dlang-requests that interacts with myip api - implement simple client-server app using dlang requests - use http requests to interact with google drive api and list its content - use dlang-requests to interact with google drive, list its content and store access token and refresh token Milestone 2 – Familiarize with gapic-generator - read protobuf documentation - build protobuf example and understand how it works - read gapic-generator documentation and look at how the generator is used to build libraries for other languages Milestone 3 – Add support Google Drive - write a proto file describing the API - write a yaml file describing certain service values - add support for Google Drive - test the generated library by inspecting and reading files, inspecting files details and creating file hierarchies Milestone 4 – Validate general case - solve issues that may appear - creating calendar events to test the support for Google Calendar - filling sheets to test the support for Google Sheets - sending and reading emails to test support for Gmail From now on, I will be posting updates weekly (or every two weeks) regarding the progress done on this project. Thanks, Robert |
September 09, 2020 Re: [SAoC] “D Language Client Libraries for Google APIs” project thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Aron | On Wednesday, 9 September 2020 at 18:35:22 UTC, Robert Aron wrote: > Milestone 1 – Familiarize with dlang-requests, dub and OAuth 2.0 I've actually done much of this before so feel free to email if you ever need a pointer. I did it with my own http lib but it is easy enough to adapt. refeshAccessToken() auto url = "https://www.googleapis.com/oauth2/v4/token"; string[string] req = [ "client_id" : config.web.client_id.get!string, "client_secret" : config.web.client_secret.get!string, "refresh_token" : auth.refresh_token.get!string, "grant_type" : "refresh_token" ]; auto v = var.fromJson(cast(string) (post(url, req).waitForCompletion.content)); getCode() auto url = "https://accounts.google.com/o/oauth2/v2/auth"; string[string] req = [ "client_id" : config.web.client_id.get!string, "redirect_uri" : "http://localhost:9292/", "scope" : [ "https://www.googleapis.com/auth/drive", "https://spreadsheets.google.com/feeds/", "https://www.googleapis.com/auth/surveys", "https://www.googleapis.com/auth/userinfo.email", ].join(" "), "access_type" : "offline", "response_type" : "code" ]; consumeCode() string[string] req = [ "client_id" : config.web.client_id.get!string, "client_secret" : config.web.client_secret.get!string, "code" : code, "redirect_uri" : "http://localhost:9292/", "grant_type" : "authorization_code" ]; auto creds_got = post(url, req); update a google sheet var json = var.emptyObject; json.valueInputOption = "RAW"; // alternative is USER_ENTERED json.data = var.emptyArray; var obj = var.emptyObject; obj.range = "WHATEVERRRRR!B1:B4"; obj.majorDimension = "COLUMNS"; // or could be ROWS to run left to right obj.values = [ ["1", "2", "3", "4"] ]; json.data ~= obj; json.includeValuesInResponse = false; auto client = new HttpClient(); auto request = client.request(arsd.http2.Uri("https://sheets.googleapis.com/v4/spreadsheets/SOMEID/values:batchUpdate"), HttpVerb.POST, cast(ubyte[]) json.toJson(), "application/json"); request.requestParameters.headers ~= "Authorization: Bearer " ~ creds.access_token.get!string; You get the idea, they aren't terribly complicated to do one piece at a time. |
September 09, 2020 Re: [SAoC] “D Language Client Libraries for Google APIs” project thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Aron | On Wednesday, 9 September 2020 at 18:35:22 UTC, Robert Aron wrote:
> Hi all,
>
> I am Robert and during this year’s edition of SAoC I will be working on the “D Language Client Libraries for Google APIs” project. This thread will be used to post further updates.
Nice project! Feel free to query for any missed features for dlang-requests in case you will base on it (although I think you should abstract http client from other code).
|
September 30, 2020 Re: [SAoC] “D Language Client Libraries for Google APIs” project thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Aron | Update for week 2 of Milestone 1 Last week I managed to do the following tasks for #SAOC2020 : - implemented a client-server app using dlang-requests - created a google account for the project and credentials for the project in Google API Console - get access and refresh tokens using curl and postman - list content of the drive associated to the created account before and after adding some files The plan for the next week is: - familiarize myself with std.json and cerealed[0] - start implementing an app that uses dlang-requests and is able to interact with google drive, list its content and store serializede access and refresh tokens Milestone 1 Update 1: [1] [0]: https://code.dlang.org/packages/cerealed [1]: https://forum.dlang.org/post/xitzuuhgxpfvnsdvdlyq@forum.dlang.org |
September 30, 2020 Re: [SAoC] “D Language Client Libraries for Google APIs” project thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Aron | On Wednesday, 30 September 2020 at 16:34:59 UTC, Robert Aron wrote:
> Update for week 2 of Milestone 1
>
> Last week I managed to do the following tasks for #SAOC2020 :
> - implemented a client-server app using dlang-requests
> - created a google account for the project and credentials for the project in Google API Console
> - get access and refresh tokens using curl and postman
> - list content of the drive associated to the created account before and after adding some files
>
> [...]
I'm very excited you're doing this. Keep up the good work. Very handy for my Web dev things.
|
October 09, 2020 Re: [SAoC] “D Language Client Libraries for Google APIs” project thread | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Aron | Update for week 3 of Milestone 1 Last week I managed to do the following tasks for #SAOC2020 : - familiarize myself with std.json and cerealed[0] - implement authentication for the app that uses dlang-requests to list the content of the drive The plan for the next week is: - continue the implementation of the app - solve any issues that may occur Milestone 1 Update 1: [1] [0]: https://code.dlang.org/packages/cerealed [1]: https://forum.dlang.org/post/xitzuuhgxpfvnsdvdlyq@forum.dlang.org |
Copyright © 1999-2021 by the D Language Foundation