I'm experiencing problems with versioning and authentication class in Restler version 3.0.0rc4.
In the index.php file the authentication class and a User class are added like this:
Defaults::$useUrlBasedVersioning = true;
$r->setAPIVersion(2);
$r->addAuthenticationClass('OAuth2');
$r->addAPIClass('User');
The authentication class looks like this:
namespace v2;
use Luracast\Restler\iAuthenticate;
class OAuth2 implements iAuthenticate
{
...
}
The User class looks like this:
namespace v2;
class User
{
...
}
Both classes are placed in a v2 folder.
Calling the authentication class (to get a token) is no problem. When the User class is called, an internal server error is encountered due to the fact that Restler can't initialize the authentication class in Restler->authenticate. The class being initialized is "OAuth2" and it should be "v2\OAuth2".
A possible solution is to add te authentication class like this:
$r->addAuthenticationClass('v2\\OAuth2');
The problem that appears with this solution is that the Resources class outputs both a v1 and a v2 url for the authentication class while the class only exists in v2:
- v1/resources/oauth2-v2.json shows an api path: "/v1/oauth2/access_token.{format}"
- v2/resources/oauth2-v2.json shows an api path: "/v2/oauth2/access_token.{format}"
Can anyone shed some light on this? Is it possible to use a different authentication class for each version of the api? How comes the Resources class shows a v1 and a v2 path for the authentication class while only the v2 path exists?