0

google python api client 初心者です。 https://developers.google.com/api-client-library/python/start/get_startedで学んでいます。サーブレットに。

ファイル api.py の python コード:

import os
import urllib2
import httplib2
import json
import requests
from apiclient.discovery import build
from oauth2client.client import flow_from_clientsecrets
from oauth2client.tools import run_flow
from oauth2client.file import Storage
from oauth2client import tools

api_version='1'
_file_="D:\API"


CLIENT_SECRETS = os.path.join(os.path.dirname(_file_))

flow=flow_from_clientsecrets(CLIENT_SECRETS,
  scope=[
      'https://www.googleapis.com/auth/devstorage.full_control',
      ],


http = httplib2.Http()
auth_http = credentials.authorize(http)

service=build('SendNotif',api_version,http=http)

req = urllib2.Request('http://example/notify')
req.add_header('Content-Type', 'application/json')

data={"message":"Hello User you are notified"}
data_json = json.dumps(data)

response = urllib2.urlopen(req, json.dumps(data))

表示されるエラーは次のとおりです。

    D:\API>python api.py
    File "api.py", line 25
    auth_http = credentials.authorize(http)
        ^
    SyntaxError: invalid syntax

私を修正するのを手伝ってください..事前に感謝します....

4

1 に答える 1