You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to easily test and develop with the MyYoast connection.
To do this we want a simple stub that emulates the behaviour of MyYoast in regards to connecting.
As this stub does need to have some behaviour I believe a simple express app should work best here.
This app should implement the following routes:
GET /connect. This will be called by Add prepare route for MyYoast connection #12131 and should accept the same parameters with the addition of a new optional mode variable. It should render a form that holds those variables in hidden inputs and has a single visible "authorize" submit button. It should POST to /connect on itself.
POST /connect. Should accept the parameters from the form above it should then:
If the mode equals bad_client_id it should instead send wrong as the client_id.
Once the request is completed it should redirect to the passed redirect_url.
If no mode is passed it should append a ?authorization_code={random_string} to the redirect.
If the mode equals no_authorization_code it should append no parameters.
If the mode equals bad_redirect it should instead redirect to the homepage of the site.
GET /login/oauth/token should return an access_token in exchange for an authorization code.
If no mode is passed it should return an object as follows: { access_token: {random_string}, refresh_token: {random_string}, expires_in: 86400 }.
If the mode equals bad_authorization_code it should return a 401.
In the plugin an environment variable should be added which, if defined, is used as the host for all requests to https://my.yoast.com and https://yoast.com.
We want to easily test and develop with the MyYoast connection.
To do this we want a simple stub that emulates the behaviour of MyYoast in regards to connecting.
As this stub does need to have some behaviour I believe a simple express app should work best here.
This app should implement the following routes:
GET /connect. This will be called by Add prepare route for MyYoast connection #12131 and should accept the same parameters with the addition of a new optionalmodevariable. It should render a form that holds those variables in hidden inputs and has a single visible "authorize" submit button. It shouldPOSTto/connecton itself.POST /connect. Should accept the parameters from the form above it should then:modeis passed it should send a separate request to the endpoint in Add connect REST endpoint for MyYoast connection #12134 with theclient_idfrom the parameters and a randomly generatedclient_secret.modeequalsbad_client_idit should instead sendwrongas the client_id.redirect_url.modeis passed it should append a?authorization_code={random_string}to the redirect.modeequalsno_authorization_codeit should append no parameters.modeequalsbad_redirectit should instead redirect to the homepage of the site.GET /login/oauth/tokenshould return an access_token in exchange for an authorization code.modeis passed it should return an object as follows:{ access_token: {random_string}, refresh_token: {random_string}, expires_in: 86400 }.modeequalsbad_authorization_codeit should return a401.In the plugin an environment variable should be added which, if defined, is used as the host for all requests to https://my.yoast.com and https://yoast.com.
Parent #12136