Wiki source code of Google Drive - Configuration

Last modified by jhurst on 2021/04/21 10:01

Show last authors
1 **Configuration: Authentication data for Digdash (service account + P12 file)**
2
3 {{ddtoc/}}
4
5 = Context =
6
7 This document explains how to get authentication information that Digdash needs to connect to a Google Drive account.
8
9 We need the following information:
10
11 * Service account
12 * P12 file
13
14 = Prerequisites =
15
16 * Être client de G Suite ou Cloud Identity
17 * Être détenteur d’une ressource Organisation activé sur votre domaine.
18
19 = Creating a new project =
20
21 Go to your Google Cloud console at:
22
23 [[https:~~/~~/console.cloud.google.com/projectselector/home/dashboard?supportedpurview=project>>url:https://console.cloud.google.com/projectselector/home/dashboard?supportedpurview=project]]
24
25
26 [[image:google_drive_config_en_html_181801a2a7fd7771.png||height="245" width="649"]]
27 \\
28
29 You can either select an existing project or create a new project.
30
31 We are going to focus on the creation.
32
33 Then click on **Create**.
34
35
36 The next screen allows you to define the project. Give it a name and choose its associated Organization.Then click on **Create**.
37
38 [[image:google_drive_config_en_html_df76892efb913ae4.png||height="392" width="389"]]
39 \\
40
41 Please wait for a few seconds, the creation takes a few seconds.
42
43 |(((
44 * [[image:google_drive_config_en_html_fe28954d2392b1bc.png||height="72" width="72"]]
45 )))|(((
46 * The Organization resource is the root node in the Google Cloud Platform resource hierarchy and is the hierarchical super node of projects. A project is then defined after an Organization and the choice is definitive.
47 )))
48
49 = Activating Google Drive API =
50
51 Go to your Google Cloud console at:
52
53 [[https:~~/~~/console.cloud.google.com/projectselector/home/dashboard?supportedpurview=project>>url:https://console.cloud.google.com/projectselector/home/dashboard?supportedpurview=project]]
54
55
56 Select the new project we just created.
57
58 [[image:google_drive_config_en_html_2aabb4d8e5e905f0.png||height="176" width="554"]]
59 \\
60
61 [[image:google_drive_config_en_html_a731c259e2abab2a.png||height="145" width="554"]]
62 \\
63
64
65 In the left side bar, go to **API & services** > **Library**
66
67 [[image:google_drive_config_en_html_9046131ba6772a4.png||height="195" width="512"]]
68 \\
69
70 Get down on the page to find **G Suite** >** Google Drive API**. Click on it.
71
72 [[image:google_drive_config_en_html_42c6bf693613b351.png||height="275" width="370"]]
73 \\
74
75 In the next screen, click on **Enable**.
76
77 [[image:google_drive_config_en_html_469c99f6b2e0fa7.png||height="262" width="431"]]
78 \\
79
80 = Creating a service account and a P12 file =
81
82 In the left side bar, go to **API & services** > **Credentials**
83
84 [[image:google_drive_config_en_html_1286373fbe7a35cc.png||height="295" width="402"]]
85 \\
86
87 In the next screen, click on **Create credentials** > **Service account key**
88
89 [[image:google_drive_config_en_html_a068c26f94e2d318.png||height="253" width="477"]]
90 \\
91
92
93 In the next screen, select **New service account** in the dropdown list **Service account** and enter a name in **Service account name.** This generates a **Service account ID** in an email address form (ending with **gserviceaccount.com**).
94
95 [[image:google_drive_config_en_html_e12bda205963e9f1.png||height="308" width="519"]]
96
97
98 In the **Role** list, select **Project** > **Owner**
99
100 In the options **Key type**, select **P12** then click on **Create**.
101
102 [[image:google_drive_config_en_html_d7b65b751eed32aa.png||height="278" width="516"]]
103
104
105 The P12 file will be downloaded automatically on your disk, please save it preciously. Click on **Close**.
106
107
108 [[image:google_drive_config_en_html_17b76a337cbe4f5f.png||height="254" width="398"]]
109
110
111 In the next page, click on **Manage service accounts** (on the right).
112
113 [[image:google_drive_config_en_html_70fd7d22ff2995f5.png||height="197" width="554"]]
114
115
116 Then, get the **Service account ID** (in an email address form).
117
118 [[image:google_drive_config_en_html_5e3c9dd16d7c4116.png||height="130" width="554"]]
119
120
121 = Precisions =
122
123 Even if you created the service account while connected to your own Google account, this service account is not related - in any way - to your own Google Drive account.
124
125 The service account is a Google account in its own right and has its own Google Drive account, its own Google Calendar, etc.
126
127 When uploading to the service account, the document will go to the service account’s Google Drive and not to the Google Drive of the Google account that was used to create the service account.
128
129 (% class="box" %)
130 (((
131 **NB** : There is no Web interface for a service account, which means that you can’t authenticate and list which documents have been uploaded. This can only be achieved via a client able to use this service account, like Digdash.
132 )))