Code Monkey home page Code Monkey logo

python-samples's Introduction

Google Workspace Python Samples Build Status

Python samples for Google Workspace APIs docs.

APIs

Admin SDK

Apps Script

Calendar

Classroom

Docs

Drive V3

Forms

Gmail

Sheets

Slides

Tasks

Lint

pylint filename.py

python-samples's People

Contributors

aliafshar avatar anuraggoogler avatar asrivas avatar awfuchs avatar btb avatar carise avatar clesleycode avatar cschalk-goog avatar googleworkspace-bot avatar grant avatar hanlee55 avatar ifurther avatar jmdobry avatar jpoehnelt avatar jsmeredith avatar mariatta avatar mattiafailla avatar mcodik avatar rajeshgogo avatar rakuista avatar renovate[bot] avatar rmccorm4 avatar slokhorst avatar sqrrrl avatar suchawla09 avatar tai271828 avatar vinay-google avatar wbooth avatar wescpy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-samples's Issues

run_flow() missing 1 required positional argument: 'flags'

https://github.com/gsuitedevs/python-samples/blob/4acb66239db78090eacd1863afbd060a4438462a/drive/quickstart/quickstart.py#L33

When I tried the quickstart.py example, I ran into the following error

run_flow() missing 1 required positional argument: 'flags'

This can be fixed by adding a call to tools.argparser.parse_args and including the returned flags in the run_flow call:

flags = tools.argparser.parse_args(args=[])

if not creds or creds.invalid:
    flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
    creds = tools.run_flow(flow, store, flags)

Hat tip to John Ruddell via StackOverflow

cannot import name 'errors' in qickstart.py

apps_script/quickstart/quickstart.py reffers to errors.HttpError.
https://github.com/gsuitedevs/python-samples/blob/2c871ce0c223b62a91ff0347f5f9eee749f5cffc/apps_script/quickstart/quickstart.py#L57
errors is not defined

Traceback (most recent call last):
  File "manage.py", line 7, in <module>
    from apiclient.discovery import build, errors
ImportError: cannot import name 'errors'

I'm guessing the resolution is to add

from apiclient import errors

works for me.

'Error opening file', 'credentials.json'

Running the quickstart sample for the first time, from the instructions I expected it to open a browser window for me to authenticate myself. Instead I got the following tracebacks:


$ python sheets.py
/home/poirier/.virtualenvs/pdfextract/lib/python3.7/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access token.json: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Traceback (most recent call last):
  File "/home/poirier/.virtualenvs/pdfextract/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 121, in _loadfile
    with open(filename, 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'credentials.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sheets.py", line 14, in <module>
    flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
  File "/home/poirier/.virtualenvs/pdfextract/lib/python3.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/poirier/.virtualenvs/pdfextract/lib/python3.7/site-packages/oauth2client/client.py", line 2135, in flow_from_clientsecrets
    cache=cache)
  File "/home/poirier/.virtualenvs/pdfextract/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 165, in loadfile
    return _loadfile(filename)
  File "/home/poirier/.virtualenvs/pdfextract/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 125, in _loadfile
    exc.strerror, exc.errno)
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'credentials.json', 'No such file or directory', 2)

Admin SDK - Reseller API: Insufficient permissions

Expected Behavior

Get resources from G Suite Reseller API

Actual Behavior

Python sample code for Admin SDK - Reseller API returns the following error:

HttpError 403 when requesting https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/login?maxResults=10&alt=json returned "Insufficient Permission"

Steps to Reproduce the Problem

  1. Just follow the steps from https://developers.google.com/admin-sdk/reseller/v1/quickstart/python

Specifications

  • Python version: 3.6.5
  • OS: Windows

Root cause

The sample code shows scopes that are for Admin SDK - Reports API (starts at line 33)

service = build('admin', 'reports_v1', http=creds.authorize(Http()))

Code should instead use the following (and adjustments must be made to call the correct resource from Reseller API):

service = build('reseller', 'v1', http=creds.authorize(Http()))

Service Account Simulation Call API

Code:
from oauth2client import file, client, tools
import base64
import dateutil.parser as parser
import csv

Creating a storage.JSON file with authentication details

SCOPES = 'https://www.googleapis.com/auth/gmail.modify' # we are using modify and not readonly, as we will be marking the messages Read
store = file.Storage('./token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('Administrator_Gmail.json', SCOPES) # gmail.json
creds = tools.run_flow(flow, store)

from google.oauth2 import service_account
SCOPES = 'https://www.googleapis.com/auth/gmail.modify'
SERVICE_ACCOUNT_FILE = './service.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
import googleapiclient.discovery
GMAIL = googleapiclient.discovery.build('gmail', 'v1', credentials=credentials) # , http=creds.authorize(Http())

print(GMAIL)

#GMAIL = discovery.build('gmail', 'v1', http=creds.authorize(Http()))

user_id = 'xx@xx'
label_id_one = 'INBOX'
label_id_two = 'UNREAD'

Getting all the unread messages from Inbox

labelIds can be changed accordingly

unread_msgs = GMAIL.users().messages().list(userId=user_id, maxResults=10).execute()

return:
<googleapiclient.discovery.Resource object at 0x000001F89DE32160>
Traceback (most recent call last):
File "D:/gmail_k/测试.py", line 36, in
unread_msgs = GMAIL.users().messages().list(userId=user_id, maxResults=10).execute()
File "C:\anzhuang\Python\lib\site-packages\googleapiclient_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\anzhuang\Python\lib\site-packages\googleapiclient\http.py", line 846, in execute
method=str(self.method), body=self.body, headers=self.headers)
File "C:\anzhuang\Python\lib\site-packages\googleapiclient\http.py", line 164, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "C:\anzhuang\Python\lib\site-packages\google_auth_httplib2.py", line 187, in request
self._request, method, uri, request_headers)
File "C:\anzhuang\Python\lib\site-packages\google\auth\credentials.py", line 122, in before_request
self.refresh(request)
File "C:\anzhuang\Python\lib\site-packages\google\oauth2\service_account.py", line 322, in refresh
request, self._token_uri, assertion)
File "C:\anzhuang\Python\lib\site-packages\google\oauth2_client.py", line 145, in jwt_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "C:\anzhuang\Python\lib\site-packages\google\oauth2_client.py", line 111, in _token_endpoint_request
_handle_error_response(response_body)
File "C:\anzhuang\Python\lib\site-packages\google\oauth2_client.py", line 61, in _handle_error_response
error_details, response_body)
google.auth.exceptions.RefreshError: ('invalid_scope: h is not a valid audience string.', '{\n "error": "invalid_scope",\n "error_description": "h is not a valid audience string."\n}')

Request had insufficient authentication scopes

Expected Behavior

ran the script from the quick start guide. installed credentials.json and activated google scripts API

Actual Behavior

Get this error "Request had insufficient authentication scopes"

Steps to Reproduce the Problem

Specifications

  • Python version (python --version)
  • OS (Mac/Linux/Windows)

Access Not Configured...?

Here's the full error text:
"
Getting the upcoming 10 events
Traceback (most recent call last):
File "quickstart.py", line 25, in
orderBy='startTime').execute()
File "/Users/mgb/anaconda3/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/mgb/anaconda3/lib/python3.6/site-packages/googleapiclient/http.py", line 842, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?timeMin=2018-07-19T12%3A49%3A23.839265Z&maxResults=10&singleEvents=true&orderBy=startTime&alt=json returned "Access Not Configured. Calendar API has not been used in project 253222910799 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar.googleapis.com/overview?project=253222910799 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">
"

no module named googleapiclient.discovery

Expected Behavior

takes to url to accept

Actual Behavior

thrown this error " File "quickstart.py", line 2, in
from googleapiclient.discovery import build
ImportError: No module named googleapiclient.discovery"

url given in documentation incase Quickstart fails also does not work

Steps to Reproduce the Problem

1.run Quickstart.py
1.
1.

Specifications

  • Python version (2.7.10)
  • OS (Mac)

UserWarning: Cannot access token.json: No such file or directory

Expected Behavior

Using a copy paste of the spreadsheet API example. I expected a print out of a few spreadsheet entries.

Actual Behavior

Error:
C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client_helpers.py:255: UserWarning: Cannot access token.json: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Traceback (most recent call last):
File "C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 86, in _validate_clientsecrets
(client_type, client_info), = clientsecrets_dict.items()
ValueError: too many values to unpack (expected 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/swalsh/Desktop/bots/Palibot/googlesheetshook.py", line 40, in
main()
File "C:/Users/swalsh/Desktop/bots/Palibot/googlesheetshook.py", line 20, in main
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
File "C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client\client.py", line 2135, in flow_from_clientsecrets
cache=cache)
File "C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 165, in loadfile
return _loadfile(filename)
File "C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 126, in _loadfile
return _validate_clientsecrets(obj)
File "C:\Users\swalsh\Anaconda3\lib\site-packages\oauth2client\clientsecrets.py", line 89, in _validate_clientsecrets
_INVALID_FILE_FORMAT_MSG + ' '
oauth2client.clientsecrets.InvalidClientSecretsError: Invalid file format. See https://developers.google.com/api-client-library/python/guide/aaa_client_secrets Expected a JSON object with a single property for a "web" or "installed" application

Process finished with exit code 1

Steps to Reproduce the Problem

  1. Follow these directions: https://developers.google.com/sheets/api/quickstart/python

Specifications

  • Python version (python --version) 3.6.6
  • OS (Mac/Linux/Windows) Win10

NameError: name 'service' is not defined

Expected Behavior

The exemple on the google calendar documentation should work , but a keep geting this error

Actual Behavior

NameError: name 'service' is not defined

Steps to Reproduce the Problem

1.I just pasted the code after i got my token
1.
1.

Specifications

  • Python version (python --version)
  • OS (Mac/Linux/Windows)

Proper browser / server configuration

The quickstart example gives us the method tools.run_flow(flow, store) to test. However, for web this code would most likely need to be run in a client by Javascript. Is there a different method we should use that would return a url of some sort that would be sent to the browser to gain authorization from the user?

Otherwise, I'm a bit confused as to how this works.

Gets stuck at "Enable the Drive API"

Expected Behavior

https://developers.google.com/drive/api/v3/quickstart/python
You click the "ENABLE THE DRIVE API" button in step 1 and it's supposed to create a file called "credentials.json".

Actual Behavior

I click the "ENABLE THE DRIVE API" button, it loads a dialog, which gets to "Enable the Drive API" and stays there. I've tried different browsers, same problem (after I log into my Drive account). Am I being an idiot? It's a common problem for me.
I don't get any error message, it just stays on that.

Steps to Reproduce the Problem

I don't know how to reproduce it for other people.

Specifications

  • Python version (python --version)
    3.7.0
  • OS (Mac/Linux/Windows)
    Windows 10

Which api of G-Suite(Calendar,Gmail,Drive) can get gmail address for all staff when use administrator account?

I use google-calendar-api to get events data of calendar form this link.

The parameter calendarId is gmail account.

In my company, I have a GSuite administrator account.

I want to get the Gmail account of the staff.

Now because I know some people's Gmail account, for example, I have 100 people's accounts. But if new employees come to the company, I don't know the Gmail account of these new employees.

So if these new employees have their new gmail of company, can I also get there new gmail with administrator account?

Which api or where can I get full staff's gmail?

from __future__ import print_function

Expected Behavior

Actual Behavior

SyntaxError: from future imports must occur at the beginning of the file

Steps to Reproduce the Problem

Specifications

  • Python version (python --version)
  • OS (Mac/Linux/Windows)

Problem when using quick start in virtualenv

Expected Behavior

For it to run

Actual Behavior

Traceback (most recent call last):
File "/home/amethyst/gmail.py", line 4, in
from googleapiclient.discovery import build
ImportError: No module named 'googleapiclient'

Steps to Reproduce the Problem

~$ virtualenv gmail
~$ source ./gmail/bin/activate
~$ pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

In IDLE, create the program from the tutorial and run it.

Specifications

  • Python version (python --version)
    Python 3.5.2
  • OS (Mac/Linux/Windows)
    Ubuntu 16.04

SSL Cirtification Issue - For Google Drive API

Expected Behavior

I am Following This Doc: https://developers.google.com/drive/api/v3/quickstart/python

Actual Behavior

I am Getting the error like :
Traceback (most recent call last):
File "C:\Aniket\Python\Upload File to google Drive\quickstart.py", line 36, in
main()
File "C:\Aniket\Python\Upload File to google Drive\quickstart.py", line 20, in main
creds = tools.run_flow(flow, store)
File "C:\Python35\lib\site-packages\oauth2client_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python35\lib\site-packages\oauth2client\tools.py", line 243, in run_flow
credential = flow.step2_exchange(code, http=http)
File "C:\Python35\lib\site-packages\oauth2client_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python35\lib\site-packages\oauth2client\client.py", line 2054, in step2_exchange
http, self.token_uri, method='POST', body=body, headers=headers)
File "C:\Python35\lib\site-packages\oauth2client\transport.py", line 282, in request
connection_type=connection_type)
File "C:\Python35\lib\site-packages\httplib2_init_.py", line 1924, in request
cachekey,
File "C:\Python35\lib\site-packages\httplib2_init_.py", line 1595, in request
conn, request_uri, method, body, headers
File "C:\Python35\lib\site-packages\httplib2_init
.py", line 1501, in conn_request
conn.connect()
File "C:\Python35\lib\site-packages\httplib2_init
.py", line 1291, in connect
self.sock = self._context.wrap_socket(sock, server_hostname=self.host)
File "C:\Python35\lib\ssl.py", line 377, in wrap_socket
_context=self)
File "C:\Python35\lib\ssl.py", line 752, in init
self.do_handshake()
File "C:\Python35\lib\ssl.py", line 988, in do_handshake
self._sslobj.do_handshake()
File "C:\Python35\lib\ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

Steps to Reproduce the Problem

Specifications

  • Python version (3.5)
  • OS (Windows)

Name 'drive_service' is not defined

Expected Behavior

The attached Python script downloads a file from Google Drive using the Drive API.

Actual Behavior

I get an error when running python clubranking.py

Traceback (most recent call last):
  File "clubranking.py", line 47, in <module>
    request = drive_service.files().get_media(fileId=file_id)
NameError: name 'drive_service' is not defined

Sussex.xlsx

I can't attach my file script so here it is:

import openpyxl
import xlrd
import requests
from openpyxl.styles import Color, PatternFill, Font, Border
from openpyxl.styles import colors

cellBGReset = PatternFill(start_color='FFFFFF',
                   end_color='FFFFFF',
                   fill_type='solid')
cellClrReset = Font(color='000000')

# loads the workbook - assumes the sussex.xlsx file is in the same directory as the script
wb = openpyxl.load_workbook("sussex.xlsx")

# load first worksheet
ws = wb.worksheets[0]

#downloading the relevant files

#rankings first

#go to the British Fencing Association website and download the rankings file (specified)
url = "https://www.britishfencing.com/wp-content/uploads/2018/10/mf_oct_2018.xls"
downloaded_file = requests.get(url)

#write the contents to a new file called rankings.xls
with open("rankings.xls", 'wb') as file:
    file.write(downloaded_file.content)

# Use xlrd to open older style .xls workbook
rank_wb = xlrd.open_workbook('rankings.xls')









#now multipliers


#go to Google Drive and download the multipliers file (specified)

file_id = '1vaCedlRFW4WLjCoClZVgmFZ2c-Kq2u1B'
request = drive_service.files().get_media(fileId=file_id)
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
    status, done = downloader.next_chunk()
    print "Download %d%%." % int(status.progress() * 100)










#write the contents to a new file called multipliers.xls
with open("multipliers.xls", 'wb') as file:
    file.write(downloaded_file.content)

# Use xlrd to open older style .xls workbook
rank_wb = xlrd.open_workbook('multipliers.xls')












# Get the first sheet of the ranked workbook
rank_ws = rank_wb.sheet_by_index(0)

# Get the total number of rows to be used to create our license list
rows = rank_ws.nrows

# Due to formatting, real numbers don't start until here
startrow = 5

# Create list of lic numbers
rank_lic = rank_ws.col_values(colx=4, start_rowx=startrow, end_rowx=rows)

# print the values in the second column of the first sheet
for row in ws['B1:B{}'.format(ws.max_row)]:
    for cell in row:
        print(cell.value)

# Putting values in same row as "Rank, Name, First name,...." adjust as necessary
ws.cell(2, 7).value = 'Fencer NIF'
ws.cell(2, 8).value = 'Points scored'


# Define function to lookup NIF and return value
def get_nif(x):
    startrow = 5
    for y in rank_lic:
        if int(x) == y:
            try:
                return int(rank_ws.cell_value(startrow, 9))
            except ValueError:
                pass
        startrow = startrow + 1
    
for row in ws['D3:D{}'.format(ws.max_row)]:
    for cell in row:
        nif_val = get_nif(cell.value)
        ws.cell(cell.row, 7).value = nif_val
        
#add a sample of text to each cell in the NIF column - needs to be updated with the formula
        
for row in ws['H3:H{}'.format(ws.max_row)]:
    for cell in row:
        ws.cell(cell.row, 8).value = "test"
        
#sum of NIF values

Grand_Total_Row = ws.max_row + 1 
ws.cell(Grand_Total_Row, 1).value = "Grand Total"
ws.cell(Grand_Total_Row, 7).value = "=SUM(G3:G{})".format(ws.max_row - 1)

#styles - currently setting top row to black text on white bg

ws['A1'].fill = cellBGReset
ws['A1'].font = cellClrReset

# While testing I always save to a different workbook so I don't overwrite my test spreadsheet
wb.save('sussex2.xlsx')

Steps to Reproduce the Problem

  1. Save attached script to clubranking.py
  2. In shell, navigate to parent folder
  3. Run python clubranking.py

admin_sdk/reports/quickstart.py HttpError 401 Access Denied

I'm attempting to follow the quickstart for the Admin SDK.

After authentication I get the following output from the quickstart.py:

Authentication successful.
Getting the last 10 login events
Traceback (most recent call last):
File "quickstart.py", line 41, in
results = service.activities().list(userKey='all', applicationName='login',maxResults=10).execute()
File "..\Miniconda2\envs\default\lib\site-packages\googleapiclient_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "..\Miniconda2\envs\default\lib\site-packages\googleapiclient\http.py", line 842, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 401 when requesting https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/login?alt=json&maxResults=10 returned "Access denied. You are not authorized to read activity records.">

Error while using this is python( django )

usage: manage.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
                 [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
                 [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
manage.py: error: unrecognized arguments: runserver
Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 157, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
    response = self._middleware_chain(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/utils/deprecation.py", line 140, in __call__
    response = self.get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/rohit/django/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/rohit/django/project/calender/views.py", line 23, in main
    creds = tools.run_flow(flow, store)
  File "/home/rohit/django/env/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/rohit/django/env/lib/python3.5/site-packages/oauth2client/tools.py", line 194, in run_flow
    flags = argparser.parse_args()
  File "/usr/lib/python3.5/argparse.py", line 1738, in parse_args
    self.error(msg % ' '.join(argv))
  File "/usr/lib/python3.5/argparse.py", line 2394, in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
  File "/usr/lib/python3.5/argparse.py", line 2381, in exit
    _sys.exit(status)
SystemExit: 2

While working this with in python (django) it says:
A server error occurred. Please contact the administrator.
and also Instance of 'Resource' has no 'events' member

Attribute error in "discovery.py" in quickstart example

Hello,

While attempting to follow the quickstart guide for the Google calendar python API https://developers.google.com/calendar/quickstart/python I run in to the following error. My code is currently identical to the one in the link.

Traceback (most recent call last):
  File "C:/Users/Topi/PycharmProjects/Random/WebDataScrape/quickstart.py", line 39, in <module>
    main()
  File "C:/Users/Topi/PycharmProjects/Random/WebDataScrape/quickstart.py", line 22, in main
    service = build('calendar', 'v3', http=creds.authorize(Http()))
  File "C:\Users\Topi\AppData\Local\Programs\Python\Python36\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\Topi\AppData\Local\Programs\Python\Python36\lib\site-packages\googleapiclient\discovery.py", line 218, in build
    requested_url = uritemplate.expand(discovery_url, params)
AttributeError: module 'uritemplate' has no attribute 'expand'

The authentication proceeds as expected by opening the browser and prompting me to allow the application. After this though the above error appears on every run.

  • Python version 3.6.3
  • Windows 10

oauth2 error '_module' dict entry

Hi,

I am trying to get the python quickstart.py to work described here:
https://developers.google.com/drive/api/v3/quickstart/python

I also ran into #12, but additionally I am having issues loading the credentials.json that I downloaded when I enabled the Drive API per the link above.

It appears that the oauth2client module is attempting to extract a '_module' entry, which doesn't exist in the credentials.json file generated during the download.

I've been using python for a while, but this is the first time in a couple of years I'm playing with the google APIs. Not sure if this is something I'm doing wrong or if I stumbled on a bug.

ipython dump below. I confirmed that the data is a dict with the contents of the credentials.json file.

[edit: Note that I moved the credentials.json file into the same directory as the quickstart.py directory.]

Thanks,

  • Josh.
(C:\Users\josh\Anaconda3\envs\py35) d:\somedir>ipython --pdb quickstart.py
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
d:\somedir\quickstart.py in <module>()
     15 #store = file.Storage('PublishPdf.json')
     16 store = file.Storage('credentials.json')
---> 17 creds = store.get()
     18 if not creds or creds.invalid:
     19     flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)

C:\Users\josh\Anaconda3\envs\py35\lib\site-packages\oauth2client\client.py in get(self)
    405         self.acquire_lock()
    406         try:
--> 407             return self.locked_get()
    408         finally:
    409             self.release_lock()

C:\Users\josh\Anaconda3\envs\py35\lib\site-packages\oauth2client\file.py in locked_get(self)
     52
     53         try:
---> 54             credentials = client.Credentials.new_from_json(content)
     55             credentials.set_store(self)
     56         except ValueError:

C:\Users\josh\Anaconda3\envs\py35\lib\site-packages\oauth2client\client.py in new_from_json(cls, json_data)
    300         # Find and call the right classmethod from_json() to restore
    301         # the object.
--> 302         module_name = data['_module']
    303         try:
    304             module_obj = __import__(module_name)

KeyError: '_module'
> c:\users\josh\anaconda3\envs\py35\lib\site-packages\oauth2client\client.py(302)new_from_json()
    300         # Find and call the right classmethod from_json() to restore
    301         # the object.
--> 302         module_name = data['_module']
    303         try:
    304             module_obj = __import__(module_name)

ipdb>

cant run people quickstart.py

Expected Behavior

as I just copy your sample, expected that it can run as designed

Actual Behavior

from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

and if run on Pycharm, there is a message: ModuleNotFoundError: No module named 'googleapiclient'
if run in cmd shell, it seems to be OK until it print a message:
Getting the first 10 users in the domain

then error message

Traceback (most recent call last):
File "contact.py", line 48, in
main()
File "contact.py", line 36, in main
results = service.users().list(customer='my_customer', maxResults=10, orderBy='email').execute()
File "C:\Program Files\Python37\lib\site-packages\googleapiclient_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\googleapiclient\http.py", line 851, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&maxResults=10&orderBy=email&alt=json returned "Domain not found.">

Steps to Reproduce the Problem

Specifications

  • Python version 3.7.2
  • OS Windows10
  • pycharm

TypeError: a bytes-like object is required, not 'str'

Expected Behavior

Succesful login & returning sheet data

Actual Behavior

TypeError: a bytes-like object is required, not 'str'

Steps to Reproduce the Problem

  1. Follow steps in QuickSetup
  2. Run Quickstart.py

Specifications

Propt returns :
Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?client_id=291562245980-3gqtl3pdj5da5ilhgfqupv1bq5166ei2.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2

Fauth%2Fspreadsheets.readonly&access_type=offline&response_type=code

If your browser is on a different machine then exit and re-run this
application with the command-line parameter

--noauth_local_webserver

Exception happened during processing of request from ('127.0.0.1', 63178)
Traceback (most recent call last):
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 313, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 344, in process_request
self.finish_request(request, client_address)
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 717, in init
self.handle()
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\http\server.py", line 414, in handle_one_request
method()
File "C:\Users\Alex Vermeulen\PycharmProjects\S1ImageFactory\venv\lib\site-packages\oauth2client\tools.py", line 100, in do_GET
s.wfile.write("<title>Authentication Status</title>")
File "C:\Users\Alex Vermeulen\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 796, in write
self._sock.sendall(b)
TypeError: a bytes-like object is required, not 'str'

Authentication has failed: invalid_client

  • Python version (python --version) 3.7
  • OS (Mac/Linux/Windows) Windows

Gmail API returns 403 error code and “Delegation denied for <user email>

I run my code with administrative privileges.
My code:

from apiclient import discovery
from apiclient import errors
from httplib2 import Http
from oauth2client import file, client, tools
import base64
from bs4 import BeautifulSoup
import dateutil.parser as parser

# Creating a storage.JSON file with authentication details
SCOPES = 'https://www.googleapis.com/auth/gmail.modify'  # we are using modify and not readonly, as we will be marking the messages Read
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
    flow = client.flow_from_clientsecrets('Administrator_Gmail.json', SCOPES)
    creds = tools.run_flow(flow, store)
GMAIL = discovery.build('gmail', 'v1', http=creds.authorize(Http()))

user_id = '[email protected]'
label_id_one = 'INBOX'
label_id_two = 'UNREAD'

unread_msgs = GMAIL.users().messages().list(userId=user_id, maxResults=10).execute()

# We get a dictonary. Now reading values for the key 'messages'
mssg_list = unread_msgs['messages']

print("Total unread messages in inbox: ", str(len(mssg_list)))

final_list = []

for mssg in mssg_list:
    temp_dict = {}
    m_id = mssg['id']  # get id of individual message
    message = GMAIL.users().messages().get(userId=user_id, id=m_id).execute()  # fetch the message using API
    payld = message['payload']  # get payload of the message
    headr = payld['headers']  # get header of the payload

    for one in headr:  # getting the Subject
        if one['name'] == 'Subject':
            msg_subject = one['value']
            temp_dict['Subject'] = msg_subject
        else:
            pass

    for two in headr:  # getting the date
        if two['name'] == 'Date':
            msg_date = two['value']
            date_parse = (parser.parse(msg_date))
            m_date = (date_parse.date())
            temp_dict['Date'] = str(m_date)
        else:
            pass

    for three in headr:  # getting the Sender
        if three['name'] == 'From':
            msg_from = three['value']
            temp_dict['Sender'] = msg_from
        else:
            pass

    temp_dict['Snippet'] = message['snippet']  # fetching message snippet

    try:

        # Fetching message body
        mssg_parts = payld['parts']  # fetching the message parts
        part_one = mssg_parts[0]  # fetching first element of the part
        part_body = part_one['body']  # fetching body of the message
        part_data = part_body['data']  # fetching data from the body
        clean_one = part_data.replace("-", "+")  # decoding from Base64 to UTF-8
        clean_one = clean_one.replace("_", "/")  # decoding from Base64 to UTF-8
        clean_two = base64.b64decode(bytes(clean_one, 'UTF-8'))  # decoding from Base64 to UTF-8
        soup = BeautifulSoup(clean_two, "lxml")
        mssg_body = soup.body()
        temp_dict['Message_body'] = mssg_body
    except:
        pass
    print(temp_dict)
    final_list.append(temp_dict)  # This will create a dictonary item in the final list
    # This will mark the messagea as read
    # GMAIL.users().messages().modify(userId=user_id, id=m_id, body={'removeLabelIds': ['UNREAD']}).execute()
print("Total messaged retrived: ", str(len(final_list)))

When I replaced userId with an employee's gmail in my company,the error message is:

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/gmail/v1/users/aXXXXXX/messages?maxResults=10&alt=json returned "Delegation denied for XXX.XXX.XXX">

Where is wrong?

returned "Insufficiet Permission"

Expected Behavior

Install the google calendar api

Actual Behavior

receive the error "insufficient permission"

Steps to Reproduce the Problem

1.Move the downloaded file to your working directory and ensure it is named credentials.json
2.run pip install --upgrade google-api-python-client oauth2client (successful)
3.run python quickstart.py
4. received the error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?timeMin=2018-08-16T09%3A19%3A45.264518Z&maxResults=10&singleEvents=true&orderBy=startTime&alt=json returned "Insufficient Permission">

Specifications

  • Python version (python --version) - 3.6
  • OS (Mac/Linux/Windows) -Windows

Cannot uninstall 'six'. It is a distutils installed project...

Expected Behavior

I am trying to follow the Python quickstart guide - what should happen when running

python quickstart.py

is what is described in the page: Drive API Python Quickstart

Actual Behavior

I run into an error:

When running python quickstart.py:

Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Traceback (most recent call last):
  File "quickstart.py", line 2, in <module>
    from googleapiclient.discovery import build
ImportError: No module named googleapiclient.discovery

Steps to Reproduce the Problem

  1. pip install --upgrade google-api-python-client oauth2client
  2. python quickstart.py

Specifications

  • Python version 2.7.10
  • OS Mojave 10.14.1

ConnectionResetError: [WinError 10054] connection fail

I want to get google calendar's information that is a project of used by python.
I prepared something that from google calendar API 's guide.
when executive then project , I got a error:
ConnectionResetError: [WinError 10054] 既存の接続はリモート ホストに強制的に切断されました。

The environment:
python version 3.6.1
windows 10
google chrome 68.0.3440.106(Official Build) (64bit)
※ I'm using a proxy to access google

The error detail information

_>python quickstart.py
E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\oauth2client\_helpers.py:255: UserWarning: Cannot access token.json: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))

Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?client_id=135970666564-rvv4lt7i90p10tcnhe8p7igmgrfkpkb0.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.readonly&access_type=offline&response_type=code

If your browser is on a different machine then exit and re-run this
application with the command-line parameter

  --noauth_local_webserver

Traceback (most recent call last):
  File "quickstart.py", line 36, in <module>
    main()
  File "quickstart.py", line 18, in main
    creds = tools.run_flow(flow, store)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\oauth2client\tools.py", line 243, in run_flow
    credential = flow.step2_exchange(code, http=http)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\oauth2client\client.py", line 2054, in step2_exchange
    http, self.token_uri, method='POST', body=body, headers=headers)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\oauth2client\transport.py", line 282, in request
    connection_type=connection_type)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\httplib2\__init__.py", line 1514, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\httplib2\__init__.py", line 1264, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\httplib2\__init__.py", line 1187, in _conn_request
    conn.connect()
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\httplib2\__init__.py", line 1050, in connect
    raise socket_err
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\site-packages\httplib2\__init__.py", line 1013, in connect
    self.sock = self._context.wrap_socket(sock, server_hostname=self.host)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 808, in __init__
    self.do_handshake()
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "E:\Users\123456789\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] 既存の接続はリモート ホストに強制的に切断されました。_

Get Spreadsheets via sheetId

Feature Request

I tried the google sheet API. As per the documentation the service.spreadsheets().values().get() only gets values of the first sheet i.e. sheetId=0.
Is there any way to get sheets data based on sheetId as well?
I couldnt find any information regarding this.

KeyError: '_module' error

I get the below error when running the script ::

PS C:\Users\nhr\Desktop\Gmail_Api> python quickstart.py
Traceback (most recent call last):
File "quickstart.py", line 32, in
main()
File "quickstart.py", line 14, in main
creds = store.get()
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 407, in get
return self.locked_get()
File "C:\Python27\lib\site-packages\oauth2client\file.py", line 54, in locked_get
credentials = client.Credentials.new_from_json(content)
File "C:\Python27\lib\site-packages\oauth2client\client.py", line 302, in new_from_json
module_name = data['_module']
KeyError: '_module'

Steps to Reproduce the Problem

I have followed the sames procedure described in https://developers.google.com/gmail/api/quickstart/python

  1. Install Python , PIP and all related modules
  2. Enabled GMAIL API and saved the credentials.json file in project directory
  3. Installed Google Client Library
  4. Copied and Saved the Quickstart.py file in project directory
  5. Run the python command to run quickstart.py

These are the files in my project directory:

09/25/2018 07:45 AM

.
09/25/2018 07:45 AM ..
09/25/2018 07:46 AM .idea
09/09/2018 09:03 PM 431 client_secret.json
09/09/2018 08:42 PM 431 credentials.json
09/09/2018 08:33 PM 4,285 index.html
09/09/2018 08:40 PM 3,076 index.js
09/09/2018 08:56 PM 1,001 quickstart.py
09/09/2018 08:47 PM 340 token.json
6 File(s) 9,564 bytes

Specifications

  • Python version (python --version) : 2.7
  • OS (Mac/Linux/Windows) : Windows 10

credentials.json downloaded as client_id.json

Expected Behavior

The code expects credentials.json to be downloaded.

Actual Behavior

What is downloaded is client_id.json.

Steps to Reproduce the Problem

  1. Follow all step to start a new project
  2. Enable google calendar API for project
  3. Receive a client_id.json file vs. the expected credentials.json file

Specifications

  • Python version (python --version)
  • OS (Mac/Linux/Windows)

no module named googleapiclient.discovery

Expected Behavior

As this failed on line two, I have no idea what could have happened

Actual Behavior

Fails on line 2 of quickstart.py

Steps to Reproduce the Problem

1.Run quickstart.py
2.Wait 0.0005 seconds
3.Get error message above

Specifications

  • Python version (python --3.5.3)
  • OS (raspberian v 9)

OSError:[Errno 98] Address already in use

Expected Behavior

On following instructions given, the program quickstart.py when executed should attempt to open a new window.

Actual Behavior

Traceback (most recent call last):
File "/home/pi/Project_Plant/codes/quickstart.py", line 64, in
main()
File "/home/pi/Project_Plant/codes/quickstart.py", line 44, in main
creds = flow.run_local_server()
File "/usr/local/lib/python3.5/dist-packages/google_auth_oauthlib/flow.py", line 407, in run_local_server
host, port, wsgi_app, handler_class=_WSGIRequestHandler)
File "/usr/lib/python3.5/wsgiref/simple_server.py", line 160, in make_server
server = server_class((host, port), handler_class)
File "/usr/lib/python3.5/socketserver.py", line 440, in init
self.server_bind()
File "/usr/lib/python3.5/wsgiref/simple_server.py", line 51, in server_bind
HTTPServer.server_bind(self)
File "/usr/lib/python3.5/http/server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.5/socketserver.py", line 454, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

--> Outputs the above error.

Steps to Reproduce the Problem

  1. Save the quickstart.py (making sure the credentials file are in the same same folder)
  2. Execute code

Specifications

  • Python version (python 3.5.3 version)
  • OS (Linux - (Raspbian on Raspberry Pi))

Instance of 'Resource' has no 'users' member

Expected Behavior

No errors

Actual Behavior

"Instance of 'Resource' has no 'users' member"

Steps to Reproduce the Problem

  1. Run the code

Specifications

  • Python version (python --version) 3.7.
  • OS (Mac/Linux/Windows) windows 10

UnicodeEncodeError

Expected Behavior

Working quickstart

Actual Behavior

Traceback when run quikstart.py

Getting the upcoming 10 events
2018-12-20 Traceback (most recent call last):
  File "D:\[omitted]\quickstart.py", line 39, in <module>
    main()
  File "D:\[omitted]\quickstart.py", line 36, in main
    print(start, event['summary'])
  File "D:\Env\myenv\lib\encodings\cp850.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f393' in position 0: character maps to <undefined>

Steps to Reproduce the Problem

  1. python quickstart.py

Specifications

  • Python 3.5.3
  • Windows 10

Error in fetch results

Traceback (most recent call last):
File "c:\Users\MyHP\Desktop\mail\demo.py", line 16, in
results = service.users().labels().list(userId='me').execute()
File "C:\Users\MyHP\AppData\Local\Programs\Python\Python36\lib\site-packages\googleapiclient_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\MyHP\AppData\Local\Programs\Python\Python36\lib\site-packages\googleapiclient\http.py", line 842, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/gmail/v1/users/me/labels?alt=json returned "Project 725026510391 is not found and cannot be used for API calls. If it is recently created, enable Gmail API by visiting https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=725026510391 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.">

cannot find token.json

Hi I tried the steps given on the link of google python quickstart. I created an account on google developer and created a project and enabled api for the project but I got an error token.json file not present. Any idea how I can get the token.json file? I get the credentials.json file when I download the client configuration files after enabling drive api but I don't get token.json file. Any help?

problem with running quickstart

Expected Behavior

Actual Behavior

Steps to Reproduce the Problem

1.Run quickstart
1.
1.

Error return

{
"error":
"code": 403,
"message": "User has not enabled the Apps Script API. Enable it by visiting https://script.google.com/home/usersettings then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"errors": [
{
"message": "User has not enabled the Apps Script API. Enable it by visiting https://script.google.com/home/usersettings then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
'

Specifications

  • Python version 3.6
  • OS Windows

Cannot pip install

Collecting google-api-python-client
Could not fetch URL https://pypi.python.org/simple/google-api-python-client/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement google-api-python-client (from versions: )
No matching distribution found for google-api-python-client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.