strategy
: The strategy helps guide the behavior of the SDK for the use case of your app. In this case, you want to set this to the constant Auth0\SDK\Configuration\SdkConfiguration::STRATEGY_API
getBearerToken()
method. This method fetches tokens from GET parameters, POST bodies, request headers, and other sources. In this case, the PHP SDK processes tokens passed from GET requests in the token
parameter or from the HTTP Authorization
header.Now, install a routing library to help direct incoming requests to your application. This isn’t a required step, but simplifies the application structure for the purposes of this quickstart.router.php
to define the routes. Copy in the code from the interactive panel to the right under the router.php tab.Now that you have configured your Auth0 application, the Auth0 PHP SDK, and you application retrieves bearer tokens from requests, the next step is to set up endpoint authorization for your project. The getBearerToken()
method you implemented above returns a Token
class that includes details on the request’s access.Since the getBearerToken()
method automatically validates and verifies the incoming request, your application determines the details of the access token by evaluating the method’s response. When the response is null, no valid token has been provided. Otherwise, inspect the contents of the response to learn more about the request.In the interactive panel to the right, you can see a check if the response is null or not to filter access to your /api/private
route.In some cases, you may want to filter access to a specific route based on the requested scopes in an access token. As shown in the interactive panel on the right, evaluate the contents of the ‘scope’ property from the getBearerToken()
method’s response to check the scopes granted by the access token.Excellent work! If you made it this far, you should now have login, logout, and user profile information running in your application.This concludes our quickstart tutorial, but there is so much more to explore. To learn more about what you can do with Auth0, check out:strategy
: The strategy helps guide the behavior of the SDK for the use case of your app. In this case, you want to set this to the constant Auth0\SDK\Configuration\SdkConfiguration::STRATEGY_API
getBearerToken()
method. This method fetches tokens from GET parameters, POST bodies, request headers, and other sources. In this case, the PHP SDK processes tokens passed from GET requests in the token
parameter or from the HTTP Authorization
header.router.php
to define the routes. Copy in the code from the interactive panel to the right under the router.php tab.