Search code examples
restler

OAuth2_GrantType_UserCredentials with Restler


Does anybody have a sample with OAuth2_GrantType_UserCredentials and Restler ? I've tried myself but it's very difficult to understand

Thanks


Solution

  • In your storage class, in my case PDO, you need to look at the following functions. Make sure you have your validations in the first one.

    public function checkUserCredentials($email, $password) {}
    public function getUserDetails($username) {}
    

    Then

    POST https://{your_server}/token
    

    With the following payload (obviously changed to suit your environment):

    [email protected]&
    password=mypassword&
    grant_type=password
    client_id=myclient_id
    

    The important one here is the grant_type, it actually is 'password' for what you are attempting.