grunt-docs-archieml v0.0.2
grunt-docs-archieml
Generate JSON file from Google Docs with ArchieML
Install
npm install grunt-docs-archieml --saveGetting credentials
- Go to https://console.developers.google.com
- Create an account
- Make sure you have the Google Drive API enabled
a. In the left sidebar click
Dashboardand then click onENABLE APIb. Click onDRIVE APIand if it’s not enabled just click onENABLE - In the right sidebar click
Credentials - Then click
Create credentials, selectoAuth client IDand then selectWeb Application - Name your Web Application
- Enter
https://developers.google.com/oauthplaygroundas an authorized redirect URL - Copy and have your
Client IDandClient Secretready - Go to https://developers.google.com/oauthplayground/
- Under
Step 1check allDrive API v3 - Click the Gear button in upper right of the page and check
Use your own OAuth credentials - Enter your
Client IDandClient secret - Go back to the
Step 1section on the left and clickAuthorize APIs - Click on
Exchange authorization code for tokensand copy the generated refresh token. - Create a file called
.credentials.jsonand add the following with your info:
{
"client_id": "your_CLIENT_ID",
"client_secret": "your_CLIENT_SECRET",
"oAuthTokens":{"refresh_token": "your_REFRESH_TOKEN"}
} The file can be saved anywhere. Recommended that you save it in your home folder so that your your secret credentials are not uploaded with your project.
Setup
Grab the Google Doc ID of the ArchieML ready document
With the Google Doc open, go to File > Publish to web, click on
PUBLISHunder the Link section and copy the ID from the URL. The ID is in between the ‘d’ and ‘pub’ section of the URL.
Enable the plugin inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-docs-archieml');Add the following within the grunt.initConfig() and modify the options as needed.
grunt.initConfig({
gdocs: {
options: {
credentials:'.credentials.json',
docsID: 'GOOGLE_DOC_ID',
dest: 'DIRECTORY_FOR_JSON_FILE'
}
},
});Default settings:
credentialsdefaults to your home folder and will look for a .credentials.json filedocsIDhas no defaultdestdefaults to a directory named json
Running
$ grunt gdocsRun the command to generate the JSON file. The file name will be the title of your Google Doc (all lowercase with underscores).