googleapiclient.http 403

34 views
Skip to first unread message

Marcos Vinicius Coltro

unread,
Feb 11, 2021, 3:21:47 PM2/11/21
to Google Content API for Shopping
Hello Guys!

I am try to import csv to postgresql using googleapiclient.discovery ,but I receive this error:

WARNING:googleapiclient.http:Encountered 403 Forbidden with reason "notAuthorized"

My code:

#########################################################



SERVICE_ACCOUNT_FILE = 'secret.json'





credentials = service_account.Credentials.from_service_account_file(


        SERVICE_ACCOUNT_FILE)


service = googleapiclient.discovery.build('sqladmin', 'v1beta4', credentials=credentials)




instance_id = 'my_instance_id'


project_id = "my_project_id"




def upload():


    processed = False



    while processed == False:


        try:


            instances_import_request_body = {


                "importContext": {
                    "fileType": "CSV",

                    "kind": "sql#importContext",


                    "uri": "gs://mybucket/my_file.csv",


                    "database": "dbmvc",


                    "csvImportOptions": {


                        "table": 'my_table'


                    }


                }


            }


            request = service.instances().import_(project=project_id, instance=instance_id, body=instances_import_request_body)


            response = request.execute()


            logger.info("Request made ...")


            process_status = False


            while not process_status:


                sleep(1)


                logger.info("Checking with GS")


                resp = service.operations().get(project=project_id, operation=response['name']).execute()


                logger.info(resp)





                if resp['status'] == "DONE":


                    logger.info("Request completed.")


                    process_status = True


                    processed=True


        except Exception as err:


            logger.info("Error: {}".format(err.args))


            logger.info("Probably an operation is in progress. Retrying after 5 seconds.")


            sleep(5)

Shopping API Forum Advisor Prod

unread,
Feb 14, 2021, 9:16:56 PM2/14/21
to mviniciu...@gmail.com, google-content-...@googlegroups.com

Hello Marcos,

 

I’m James from the Content API Team. Thank you for reaching out to us. I’m afraid that your concern is out of our scope. That said, please keep in mind that our team can only provide support regarding Content API technical issues.

 

If you have any questions regarding Content API, feel free to contact us.

 

Regards,

Google Logo
James Howell Abarsoza
Content API for Shopping Team
 


ref:_00D1U1174p._5004Q2CQBWT:ref
Reply all
Reply to author
Forward
0 new messages