The library provides helper methods to manage the OAuth 2.0 lifecycle.
1. Build the Authorization URL
Use buildAuthorizationEndpoint() to generate the URL where you should redirect your users to authorize your application.
2. Exchange Code for Access Token
After the user is redirected back to your redirect_uri with a code, use accessToken() to exchange that code for a permanent access token.
3. Client Credentials Flow
For machine-to-machine authentication without user intervention, use clientCredentials($scope) to obtain a token.
Methods:
buildAuthorizationEndpoint(string $redirect_uri, string|array $scope = 'public', string|null $state = null): stringaccessToken(string $code, string $redirect_uri): arrayclientCredentials(string|array $scope = 'public'): array
// 1. Generate URL for user redirect
$authUrl = $vimeo->buildAuthorizationEndpoint('https://your-site.com/callback', ['public', 'private'], 'random_state_string');
// 2. After redirect, exchange code for token
$tokenResponse = $vimeo->accessToken($_GET['code'], 'https://your-site.com/callback');
$newAccessToken = $tokenResponse['body']['access_token'];
// 3. Update the client with the new token
$vimeo->setToken($newAccessToken);