I want to deploy a google script app project using python script, but getting unauthorized error
I am trying to deploy a google script app using python script as I want to automate it for a number of google script projects.
So I tried the following code below
credentials_data = {"token": "TOKEN_GENERATED_AFTER_LOGIN", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "XXXX.apps.googleusercontent.com", "client_secret": "XXXXX", "scopes": ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/script.projects", "https://www.googleapis.com/auth/script.deployments", "https://www.googleapis.com/auth/script.deployments.readonly"], "expiry": "2024-04-03T17:38:59.298063Z"}
credentials = Credentials.from_authorized_user_info(credentials_data)
script_service = build('script', 'v1', credentials=credentials)
deployment_config = {
'versionNumber': 1,
'description': 'Initial deployment'
}
request = script_service.projects().deployments().create(
body=deployment_config,
scriptId=script_id
)
response = request.execute()
But the problem is I am getting this error
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"service": "script.googleapis.com",
"method": "google.apps.script.management.v1.DeploymentsService.ListDeployments"
}
}
]
}
}