I've shared a Google Sheet with my Google Service account email, which looks something like:
myappname-service@myappname-266229.iam.gserviceaccount.com
This permits my application to access that Google Sheet.
I'd like to be able to share the Google Sheet with a custom email address (e.g. google@myappname.com) aliased to that ugly autogenerated service account email (myappname-service@myappname-266229.iam.gserviceaccount.com
).
How could I go about doing this?
edit:
Example of code used for interacting with Google APIs
from google_auth_httplib2 import AuthorizedHttp
from google.oauth2 import service_account
import pygsheets
def _get_gc():
scope = ['https://www.googleapis.com/auth/spreadsheets']
credentials = service_account.Credentials.from_service_account_file(
settings.GOOGLE_SERVICE_AUTH_FILE,
scopes=scope,
)
http = AuthorizedHttp(credentials, http=HTTP)
logger.info('Created GC creds, returning...')
return pygsheets.authorize(custom_credentials=credentials, http=http)
def do_something(url):
gc = _get_gc()
spreadsheet = gc.open_by_url(url)