Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/oauth2dl/README.md

Issue 29833582: Issue 4954 - Implement a downloader script supporting OAuth2 authentication/authorization (Closed)
Patch Set: Addressed comments from patch#1 Created July 31, 2018, 9:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # oauth2dl
2
3 This is a script that downloads a file from a given URL
4 using Google Oauth2 for service accounts.
5
6 ## Dependencies
7
8 * [Python 2.7](https://www.python.org/download/releases/2.7/)
9 * [oauth2client](https://github.com/google/oauth2client) Using pip:
10 ```commandline
11 pip install oauth2client
12 ```
13 * [httplib2](https://github.com/httplib2/httplib2) Using pip:
14 ```commandline
15 pip install httplib2
16 ```
17
18 ## Running the script
19
20 The script can be run as a module, using the following command:
21
22 ```commandline
23 python -m sitescripts.oauth2dl.bin.oauth2dl [-k <key-file>] [-s <scope>] [-o <path>] <url>
24 ```
25
26 where:
27 * `key-file` = Path to the key file used to authenticate. If not provided, uses
28 the `OAUTH2DL_KEY` environment variable.
29 * `scope` = The scope used when authenticating(eg:
30 https://www.googleapis.com/auth/drive). If not provided, uses the `OAUTH2DL_SCOP E`
31 environment variable.
32
33 * `path` = Path where to save the downloaded file. If not provided, the
34 contents will be sent to `stdout`
35 * `url` = URL of the file we're trying to download. For a Google Drive
36 file, the url should look something like:
37 `https://www.googleapis.com/drive/v3/files/<fileID>?alt=media`
38
39 The script can also be run directly from the file, using:
40 ```commandline
41 python sitescripts/oauth2dl/bin/oauth2dl.py [-k <key-file>] [-s <scope>] [-o <path>] <url>
42 ```
43
44 ## Getting the key file
45
46 The key file can be obtained by following the instructions available
47 [here](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).
48
49 It should be a JSON with the following format:
50 ```json
51 {
52 "type": "service_account",
53 "project_id": <project_id>,
54 "private_key_id": <private_key_id>,
55 "private_key": <RSA-encrypted private key>,
56 "client_email": "<service_account_id>@<project_id>.iam.gserviceaccount.com ",
57 "client_id": <client_id>,
58 "auth_uri": "https://accounts.google.com/o/oauth2/auth",
59 "token_uri": "https://accounts.google.com/o/oauth2/token",
60 "auth_provider_x509_cert_url": ...,
61 "client_x509_cert_url": ...
62 }
63 ```
64
65 In order to download the file the *service account* (i.e. the email in
66 the `client_id` field from the key file) should be granted access to it.
67
68
OLDNEW
« .gitignore ('K') | « .gitignore ('k') | sitescripts/oauth2dl/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld