Reputation: 91
I'm struggling with OAuth2 authorization, authentication and user linking. What I've done so far:
I've created a client and it's secret. All redirects and so on are working. Grant type password works for own native app (e.g. Android and iOS)
But for access token, user_id
is NULL
if grant type is Authorization code.
How can I assign a user to access token or authorization code?
Is there a module for Apigility to provide login screen? I only get asked for "allow" or "disallow" application but I'm never asked for a username and password.
Update:
Question is related to provide OAuth2 access third party pages, e.g. IFTTT. They open /oauth/authorize
page and somewhere I have guide user to a login?! to determine related user? Is there an existing module for this?
Third party sites, e.g. IFTTT do not use password grant type for security reasons. And compared to other pages the workflow is: Is user authenticated? Yes: Show Accept/Decline button. No: User has to login and will be redirected afterwards to /oauth/authorize page. So is there a common way in apigility to check if user is logged in and if not, redirect to a login mask?
Upvotes: 2
Views: 319
Reputation: 2041
To authenticate with username and password using OAuth2 you should use the grant_type=password
.
I'm not sure if there is a login screen in Apigility. But I don't think it should have it, because Apigility already allow this by one or more endpoints through OAuth2, more specifically by OAuth2 Server Library for PHP.
How to do
oauth_clients.grant_types
column) set "password"
.Create a post to the authetication url like below.
url=localhost:8080/oauth
, where localhost:8080
is where the apigility is running and /oauth
is the configured auth adapter url.payload:
{
"username": "USERNAME",
"password": "PASSWORD",
"grant_type": "password",
"client_id": "CLIENT_ID"
}
Upvotes: 1