Store_Api::getCustomerLoginToken( $id, string $redirectUrl = '', string $requestIp = '', int $channel_id )
Summary
Get customr login token by id
Parameters
- $id
-
(Required)
- $redirectUrl
-
(string) (Optional)
Default value: ''
- $requestIp
-
(string) (Optional)
Default value: ''
- $channel_id
-
(int) (Required)
Return
(string)
Source
File: src/BigCommerce/Api/Store_Api.php
public function getCustomerLoginToken( $id, $redirectUrl = '', $requestIp = '', $channel_id = 0 ) { $config = $this->apiClient->getConfig(); $client_id = $config->getClientId(); $secret = $config->getClientSecret(); $store_hash = $this->get_store_hash(); if ( empty( $secret ) ) { throw new \Exception( 'Cannot sign customer login tokens without a client secret' ); } $payload = [ 'iss' => $client_id, 'iat' => $this->get_server_time(), 'jti' => bin2hex( random_bytes( 32 ) ), 'operation' => 'customer_login', 'store_hash' => $store_hash, 'customer_id' => $id, ]; if ( ! empty( $redirectUrl ) ) { $payload[ 'redirect_to' ] = $redirectUrl; } if ( ! empty( $requestIp ) ) { $payload[ 'request_ip' ] = $requestIp; } if ( ! empty( $channel_id ) ) { $payload[ 'channel_id' ] = (int) $channel_id; } return JWT::encode( $payload, $secret, 'HS256' ); }