Google Ads Api Oauth Catchable Exception
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- php
- Área
- api, authentication
Línea de trabajo
Comienza siguiendo la ruta de los refresh tokens expirados a través de vendor/google/auth/src/OAuth2.php y vendor/google/auth/src/Credentials/UserRefreshCredentials.php, usando la respuesta invalid_grant reportada como caso de reproducción. Determina qué excepción llega al llamador y si la biblioteca expone un punto fiable para su gestión. Se considera terminado cuando el fallo puede distinguirse y gestionarse de forma predecible, con cobertura de pruebas o documentación sobre el comportamiento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
try {
// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId(env('GOOGLE_ADS_CLIENT_ID'))
->withClientSecret(env('GOOGLE_ADS_CLIENT_SECRET'))
->withRefreshToken($refreshToken)
->build();
} catch (\Throwable $e) {
return $this->job->fail();
}
try {
// Construct a Google Ads client configured from a properties file and the
// OAuth2 credentials above.
$googleAdsClient = (new GoogleAdsClientBuilder())
->withOAuth2Credential($oAuth2Credential)
->withDeveloperToken(env('GOOGLE_ADS_DEVELOPER_TOKEN'))
->withLoginCustomerId($customerID)
->withTransport('rest')
->build();
} catch (\Throwable $e) {
return $this->job->fail();
}
So i have the code above which is using the google auth library to create the oauth credential, however some of our clients have expired refresh tokens: This spits out:
Message
Client error: POST https://oauth2.googleapis.com/token resulted in a 400 Bad Request response:
{
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}
Level
ERROR
Exception
{
"class": "GuzzleHttp\\Exception\\ClientException",
"message": "Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response:\n{\n \"error\": \"invalid_grant\",\n \"error_description\": \"Token has been expired or revoked.\"\n}\n",
"code": 400,
"file": "/usr/local/bigtop/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113",
"trace": [
"/usr/local/bigtop/vendor/guzzlehttp/guzzle/src/Middleware.php:69",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:204",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:153",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/TaskQueue.php:48",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:248",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:224",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:269",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:226",
"/usr/local/bigtop/vendor/guzzlehttp/promises/src/Promise.php:62",
"/usr/local/bigtop/vendor/guzzlehttp/guzzle/src/Client.php:123",
"/usr/local/bigtop/vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php:47",
"/usr/local/bigtop/vendor/google/auth/src/OAuth2.php:544",
"/usr/local/bigtop/vendor/google/auth/src/Credentials/UserRefreshCredentials.php:114",
"/usr/local/bigtop/vendor/google/auth/src/CredentialsLoader.php:214",
"/usr/local/bigtop/vendor/google/gax/src/CredentialsWrapper.php:208",
"/usr/local/bigtop/vendor/google/gax/src/Transport/HttpUnaryTransportTrait.php:111",
"/usr/local/bigtop/vendor/google/gax/src/Transport/RestTransport.php:110",
"/usr/local/bigtop/vendor/google/gax/src/GapicClientTrait.php:608",
"/usr/local/bigtop/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php:61",
"/usr/local/bigtop/vendor/google/gax/src/Middleware/FixedH
Is there a good way to be able to catch that since it's being caught inside the libraries and i'm not seeing a way to properly handle that exception.
- Lenguaje dominante
- PHP
- Estrellas
- 1.4k
- Forks
- 197
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 89/100
backdrop-contrib/commerce#65 ·
-
backend enhancement good first issue php
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
enhancement good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Evalogical-Inc/devReady#66 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
mollie/PrestaShop#1627 ·
Los mantenedores suelen responder en 5 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
FriendsOfFlarum/follow-tags#118 ·