|
@@ 205-220 (lines=16) @@
|
| 202 |
|
* @return array|mixed |
| 203 |
|
* @throws \Exception |
| 204 |
|
*/ |
| 205 |
|
public function login($username, $password) |
| 206 |
|
{ |
| 207 |
|
$url = $this->salesforceLoginUrl . 'services/oauth2/token'; |
| 208 |
|
|
| 209 |
|
$post_data = [ |
| 210 |
|
'grant_type' => 'password', |
| 211 |
|
'client_id' => $this->clientId, |
| 212 |
|
'client_secret' => $this->clientSecret, |
| 213 |
|
'username' => $username, |
| 214 |
|
'password' => $password |
| 215 |
|
]; |
| 216 |
|
|
| 217 |
|
$response = $this->makeRequest('post', $url, ['form_params' => $post_data]); |
| 218 |
|
|
| 219 |
|
return json_decode($response->getBody(), true); |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
/** |
| 223 |
|
* Complete the oauth process by confirming the code and returning an access token |
|
@@ 230-245 (lines=16) @@
|
| 227 |
|
* @return array|mixed |
| 228 |
|
* @throws \Exception |
| 229 |
|
*/ |
| 230 |
|
public function authorizeConfirm($code, $redirect_url) |
| 231 |
|
{ |
| 232 |
|
$url = $this->salesforceLoginUrl . 'services/oauth2/token'; |
| 233 |
|
|
| 234 |
|
$post_data = [ |
| 235 |
|
'grant_type' => 'authorization_code', |
| 236 |
|
'client_id' => $this->clientId, |
| 237 |
|
'client_secret' => $this->clientSecret, |
| 238 |
|
'code' => $code, |
| 239 |
|
'redirect_uri' => $redirect_url |
| 240 |
|
]; |
| 241 |
|
|
| 242 |
|
$response = $this->makeRequest('post', $url, ['form_params' => $post_data]); |
| 243 |
|
|
| 244 |
|
return json_decode($response->getBody(), true); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
/** |
| 248 |
|
* Get the url to redirect users to when setting up a salesforce access token |