Is there any way to use sensitive config files?

Hi,
I am trying to find the way to test python scripts using Sheets API.

Sheets API is to read and write Google Spread Sheet, which requires to load credential information via json file in the script.

Here is an example:

import gspread
import json

# ---- create Google Drive Service
from apiclient.discovery import build
import httplib2
from oauth2client.service_account import ServiceAccountCredentials 

class sheetConnector:
    def __init__(self):
        scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']

        #Load credentials
        credentials = ServiceAccountCredentials.from_json_keyfile_name('XXX.json', scope)
        ...

It is not good to add a file with credential information to the GitHub repository to run CircleCI processes.
But it seems that there is no way to add file through the web console of CircleCI like environment variables.

I would appreciate if there is any way to add conf file and use it in the test process securely.

Thank you.

Hi @m-oshiro. Welcome to the CircleCI community!

What I suggest is to base64-encode the file, and add it as an environment variable.

Then you’ll need to decode it within your job, so you can use it in the script.

Hi @yannCI.
It works! Thank you for the quick and precise advice It helped me a lot.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.