Improve "Private App" API usage
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con src/Clients/Rest.php alrededor del encabezado del token de acceso y sigue Context::initialize y sus comprobaciones de inicialización. Confirma el flujo directo deseado de Rest($domain, $storeApiToken), incluidos los valores predeterminados indicados y el comportamiento del registro, y verifica después que el comportamiento existente de la API y las pruebas sigan pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Overview/summary
Currently using this library when connecting to a private app is confusing.
It takes quite a long time to work out what you are doing, when it feels like it could be really simple.
Motivation
In our usecase, we only want to consume the Shopify admin api via REST, with a private app access token.
Currently to do that you have to have the following code:
Context::initialize(
'xxx', // Not used
'yyy', // Not used
'read_orders, write_orders', // Not used
'http://localhost', // Not used
new FileSessionStorage('/tmp/php_sessions'), // Not used
'latest',
false, // Not used
false, // Needs to (incorrectly) be set to false
);
$rest = new Rest($domain, $storeApiToken);
This is not helped by the fact that there is a bug on this line:
https://github.com/Shopify/shopify-php-api/blob/main/src/Clients/Rest.php#L46
So you actually have to Context::initialize with "privateApp" to to false, so it uses the access token not the secret key.
$headers[HttpHeaders::X_SHOPIFY_ACCESS_TOKEN] =
Context::$IS_PRIVATE_APP ? Context::$API_SECRET_KEY : $this->accessToken;
There is barely any point in having to call Context::initialize, the only reason for doing it is to:
- Set Context::$IS_INITIALIZED (to prevent an exception)
- Default Context::$HTTP_CLIENT_FACTORY = new HttpClientFactory();
In an ideal situation I would just need to do this:
$rest = new Rest($domain, $storeApiToken);
Possible Improvements
- Remove the need to call Context::initialize
- Default the API version to 'unstable'
- Default the initialization of $HTTP_CLIENT_FACTORY if null
- Don't throw an exception during log if not initialized
Happy to contribute these changes, if you are welcome to receive them.
- Lenguaje dominante
- PHP
- Estrellas
- 473
- Forks
- 193
- 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
-
maintenance
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hawk-digital-environments/HAWKI#443 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
crazy-goat/rabbit-stream#799 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Code Quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Automattic/safe-publish#708 ·
Los mantenedores suelen responder en 1 día