@@ -21,24 +21,24 @@ public static function getJWT($iss, $aud, $sub, $privateKey)
2121 return JWT ::encode ($ payload , $ privateKey , 'RS256 ' );
2222 }
2323
24- public function authenticate ($ url = null )
24+ public function authenticate ($ fullInstanceUrl = null )
2525 {
26- $ domain = $ url ?? $ this ->credentials ['loginURL ' ] . '/services/oauth2/token ' ;
27- $ username = $ this ->credentials ['username ' ];
28- // OAuth Client ID
26+ $ fullInstanceUrl = $ fullInstanceUrl ?? $ this ->getInstanceURL () . '/services/oauth2/token ' ;
27+
2928 $ consumerKey = $ this ->credentials ['consumerKey ' ];
30- // Private Key
29+ $ loginUrl = $ this ->credentials ['loginURL ' ];
30+ $ username = $ this ->credentials ['username ' ];
3131 $ privateKey = $ this ->credentials ['privateKey ' ];
3232
3333 // Generate the form parameters
34- $ assertion = static ::getJWT ($ consumerKey , $ domain , $ username , $ privateKey );
34+ $ assertion = static ::getJWT ($ consumerKey , $ loginUrl , $ username , $ privateKey );
3535 $ parameters = [
3636 'grant_type ' => 'urn:ietf:params:oauth:grant-type:jwt-bearer ' ,
3737 'assertion ' => $ assertion
3838 ];
3939
4040 // \Psr\Http\Message\ResponseInterface
41- $ response = $ this ->httpClient ->request ('post ' , $ domain , ['form_params ' => $ parameters ]);
41+ $ response = $ this ->httpClient ->request ('post ' , $ fullInstanceUrl , ['form_params ' => $ parameters ]);
4242
4343 $ authToken = json_decode ($ response ->getBody ()->getContents (), true );
4444
0 commit comments