-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarketoProvider.php
More file actions
75 lines (67 loc) · 2.09 KB
/
MarketoProvider.php
File metadata and controls
75 lines (67 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace VPMV\Marketo\Oauth;
use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken as LeagueAccessToken;
use Psr\Http\Message\ResponseInterface;
class MarketoProvider extends AbstractProvider implements MarketoProviderInterface
{
public string $baseUrl; // gets assigned in AbstractProvider constructor
public function __construct(string $clientId, string $clientSecret, string $baseUrl)
{
parent::__construct([
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'baseUrl' => $baseUrl,
]);
}
public function refreshAccessToken(array $options = []): AccessTokenInterface
{
$leagueAT = $this->getAccessToken('client_credentials', $options);
return new AccessToken(
$leagueAT->getToken(),
$leagueAT->getExpires()
);
}
/**
* Returns the base URL for requesting an access token
*
* @param array $params
*
* @return string
*/
public function getBaseAccessTokenUrl(array $params)
{
return $this->baseUrl . "/identity/oauth/token";
}
/**
* Check a provider response for errors.
*
* @param ResponseInterface $response
* @param array|string $data
*
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/
protected function checkResponse(ResponseInterface $response, $data)
{
if ($response->getStatusCode() >= 400) {
throw new IdentityProviderException(
$data['error'] ?: $response->getReasonPhrase(),
$response->getStatusCode(),
$response->getBody()
);
}
}
public function getBaseAuthorizationUrl()
{
}
public function getResourceOwnerDetailsUrl(LeagueAccessToken $token)
{
}
protected function getDefaultScopes()
{
}
protected function createResourceOwner(array $response, LeagueAccessToken $token)
{
}
}