null, // filled by the caller (has the secret at hand). 'redirect_uri' => home_url( 'wp-load.php' ), 'scopes' => $this->one_drive_scopes(), ]; if ( null !== $state ) { $config['state'] = $state; } return $config; } /** * Extracts obtained/expires_in supporting array|object|ClientState|null. * Returns [obtained:int, expires:int]. Falls back to (0, 0) to force renewal if missing. * * @param mixed $client_state * @return array{0:int,1:int} [obtained, expires_in] */ protected function extract_token_times( $client_state ): array { $token = null; if ( $client_state instanceof ClientState ) { $token = $client_state->token ?? null; } elseif ( is_object( $client_state ) ) { $token = $client_state->token ?? null; } elseif ( is_array( $client_state ) ) { $token = $client_state['token'] ?? null; } if ( is_array( $token ) ) { $obtained = (int) ( $token['obtained'] ?? 0 ); $data = $token['data'] ?? []; $expires = is_array( $data ) ? (int) ( $data['expires_in'] ?? 0 ) : ( is_object( $data ) ? (int) ( $data->expires_in ?? 0 ) : 0 ); return [ $obtained, $expires ]; } if ( is_object( $token ) ) { $obtained = (int) ( $token->obtained ?? 0 ); $data = $token->data ?? null; $expires = is_array( $data ) ? (int) ( $data['expires_in'] ?? 0 ) : ( is_object( $data ) ? (int) ( $data->expires_in ?? 0 ) : 0 ); return [ $obtained, $expires ]; } return [ 0, 0 ]; } }