160 $token = $this->settings[
"userToken"];
163 "idpId" => $this->idpId,
165 "successUrl" => $this->successUrl,
166 "failureUrl" => $this->failureUrl
169 curl_setopt_array($curl, array(
170 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/idp_intents",
171 CURLOPT_RETURNTRANSFER =>
true,
172 CURLOPT_ENCODING =>
'',
173 CURLOPT_MAXREDIRS => 10,
174 CURLOPT_TIMEOUT => 0,
175 CURLOPT_FOLLOWLOCATION =>
true,
176 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
177 CURLOPT_CUSTOMREQUEST =>
'POST',
178 CURLOPT_POSTFIELDS => json_encode($request),
179 CURLOPT_HTTPHEADER => array(
180 "Content-Type: application/json",
181 "Accept: application/json",
182 "Authorization: Bearer $token"
186 $response = json_decode(curl_exec($curl));
187 if(isset($response->code)) {
188 throw new Exception(
"Error-Code: " . $response->code .
" Message: " . $response->message);
190 $this->authUrl = $response->authUrl;
200 $token = $this->settings[
"userToken"];
202 curl_setopt_array($curl, array(
203 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/idp_intents/$this->idpIntentId",
204 CURLOPT_RETURNTRANSFER =>
true,
205 CURLOPT_ENCODING =>
'',
206 CURLOPT_MAXREDIRS => 10,
207 CURLOPT_TIMEOUT => 0,
208 CURLOPT_FOLLOWLOCATION =>
true,
209 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
210 CURLOPT_CUSTOMREQUEST =>
'POST',
211 CURLOPT_POSTFIELDS =>
"{
212 \"idpIntentToken\": \"$this->idpToken\"
214 CURLOPT_HTTPHEADER => array(
215 "Content-Type: application/json",
216 "Accept: application/json",
217 "Authorization: Bearer $token"
221 $response = json_decode(curl_exec($curl));
222 if(isset($response->code)) {
223 throw new Exception(
"Error-Code: " . $response->code .
" Message: " . $response->message);
225 $this->idpAccessToken = $response->idpInformation->oauth->accessToken;
226 $this->idpUserId = $response->idpInformation->userId;
227 $this->idpUserName = $response->idpInformation->userName;
228 $this->idpEmail = $response->idpInformation->rawInformation->email;
229 $this->isIdpEmailVerified = $response->idpInformation->rawInformation->email_verified;
230 $this->idpPicture = $response->idpInformation->rawInformation->picture;
231 $this->idpProfile = $response->idpInformation->rawInformation->profile;
232 $this->idpRawInformation = json_encode($response->idpInformation->rawInformation);
242 $token = $this->settings[
"serviceUserToken"];
245 "idpId" => $this->idpId,
246 "userId" => $this->idpUserId,
247 "userName" => $this->idpUserName
251 curl_setopt_array($curl, array(
252 CURLOPT_URL => $this->settings[
"domain"] .
"/v2beta/users/$this->userid/links",
253 CURLOPT_RETURNTRANSFER =>
true,
254 CURLOPT_ENCODING =>
'',
255 CURLOPT_MAXREDIRS => 10,
256 CURLOPT_TIMEOUT => 0,
257 CURLOPT_FOLLOWLOCATION =>
true,
258 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
259 CURLOPT_CUSTOMREQUEST =>
'POST',
260 CURLOPT_POSTFIELDS => json_encode($request),
261 CURLOPT_HTTPHEADER => array(
262 "Content-Type: application/json",
263 "Accept: application/json",
264 "Authorization: Bearer $token"
268 $response = json_decode(curl_exec($curl));
269 if(isset($response->code)) {
270 throw new Exception(
"Error-Code: " . $response->code .
" Message: " . $response->message);