from__future__importprint_functionimportargparseimportsysfromgoogleapiclientimportsample_tools# Declare command-line flags.argparser=argparse.ArgumentParser(add_help=False)argparser.add_argument('property_uri',type=str,help=('Site or app URI to query data for (including ''trailing slash).'))argparser.add_argument('start_date',type=str,help=('Start date of the requested date range in ''YYYY-MM-DD format.'))argparser.add_argument('end_date',type=str,help=('End date of the requested date range in ''YYYY-MM-DD format.'))defmain(argv):service,flags=sample_tools.init(argv,'webmasters','v3',__doc__,__file__,parents=[argparser],scope='https://www.googleapis.com/auth/webmasters.readonly')# First run a query to learn which dates we have data for. You should always# check which days in a date range have data before running your main query.# This query shows data for the entire range, grouped and sorted by day,# descending; any days without data will be missing from the results.request={'startDate':flags.start_date,'endDate':flags.end_date,'dimensions':['date']}response=execute_request(service,flags.property_uri,request)print_table(response,'Available dates')defexecute_request(service,property_uri,request):"""Executes a searchAnalytics.query request.
Args:
service: The webmasters service to use when executing the query.
property_uri: The site or app URI to request data for.
request: The request to be executed.
Returns:
An array of response rows.
"""returnservice.searchanalytics().query(siteUrl=property_uri,body=request).execute()defprint_table(response,title):"""Prints out a response table.
Each row contains key(s), clicks, impressions, CTR, and average position.
Args:
response: The server response to be printed as a table.
title: The title of the table.
"""print('\n --'+title+':')if'rows'notinresponse:print('Empty response')returnrows=response['rows']row_format='{:<20}'+'{:>20}'*4print(row_format.format('Keys','Clicks','Impressions','CTR','Position'))forrowinrows:keys=''# Keys are returned only if one or more dimensions are requested.if'keys'inrow:keys=u','.join(row['keys']).encode('utf-8').decode()print(row_format.format(keys,row['clicks'],row['impressions'],row['ctr'],row['position']))if__name__=='__main__':main(sys.argv)``````json{"installed":{"client_id":"INSERT CLIENT ID HERE","client_secret":"INSERT CLIENT SECRET HERE","redirect_uris":[],"auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token"}}```I was expecting the tablewithresults butImgetting url directedisnotmatched.I even tried'localhost:8080'inthe redirected url but itisnotworking