0

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

Thanks

Alban
  • 23
  • 1
  • 4

2 Answers2

0

Not sure exactly what you're asking. If you have OAuth 2 set up already on your server, you just need to change the grant_type to 'client_credentials' and pass the client_id and client_secret in exchange for the token. For example, on my index.php page, I was able to get a token by passing:

index.php/grant?grant_type=client_credentials&client_id=demoapp&client_secret=demopass

Hope this helps.

0

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=me@myemail.com&
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.

Dan Power
  • 1,141
  • 1
  • 12
  • 18