@@ -13,6 +13,7 @@ class Restforce implements RestforceInterface
1313 public const USER_INFO_ENDPOINT = 'RESOURCE_OWNER ' ;
1414
1515 private const DEFAULT_API_VERSION = 'v38.0 ' ;
16+ private const DEFAULT_AUTH_URL = 'https://login.salesforce.com ' ;
1617
1718 /** @var string */
1819 private $ clientId ;
@@ -26,6 +27,8 @@ class Restforce implements RestforceInterface
2627 private $ accessToken ;
2728 /** @var string */
2829 private $ apiVersion ;
30+ /** @var string */
31+ private $ authUrl ;
2932 /** @var OAuthRestClient|null */
3033 private $ oAuthRestClient ;
3134
@@ -35,7 +38,8 @@ public function __construct(
3538 ?OAuthAccessToken $ accessToken = null ,
3639 ?string $ username = null ,
3740 ?string $ password = null ,
38- ?string $ apiVersion = null
41+ ?string $ apiVersion = null ,
42+ ?string $ authUrl = null
3943 ) {
4044 if ($ accessToken === null && $ username === null && $ password === null ) {
4145 throw RestforceException::minimumRequiredFieldsNotMet ();
@@ -45,12 +49,17 @@ public function __construct(
4549 $ apiVersion = self ::DEFAULT_API_VERSION ;
4650 }
4751
52+ if ($ authUrl === null ) {
53+ $ authUrl = self ::DEFAULT_AUTH_URL ;
54+ }
55+
4856 $ this ->apiVersion = $ apiVersion ;
4957 $ this ->clientId = $ clientId ;
5058 $ this ->clientSecret = $ clientSecret ;
5159 $ this ->accessToken = $ accessToken ;
5260 $ this ->username = $ username ;
5361 $ this ->password = $ password ;
62+ $ this ->authUrl = $ authUrl ;
5463 }
5564
5665 public function create (string $ sobjectType , array $ data ): ResponseInterface
@@ -118,7 +127,7 @@ private function getOAuthRestClient(): RestClientInterface
118127 new GuzzleRestClient ('https://na1.salesforce.com ' ),
119128 $ this ->apiVersion
120129 ),
121- new GuzzleRestClient (' https://login.salesforce.com ' ),
130+ new GuzzleRestClient ($ this -> authUrl ),
122131 $ this ->clientId ,
123132 $ this ->clientSecret ,
124133 $ this ->username ,
0 commit comments