static TwitchInGames::string_t const clientId= L"05zrlud5jr2b73vijreb681r505eox";

static TwitchInGames::tstring DoFlow1() {
	static TwitchInGames::string_t const redirectUri= L"http://192.168.43.102:27077/auth";

	// Communicate with the "server" to complete the flow.
	WSADATA wsaData;
	WSAStartup(MAKEWORD(2, 2), &wsaData);
	TwitchInGames::tstring token;

	// Create a client socket.
	auto clientSocket= socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
	if(clientSocket != INVALID_SOCKET) {
		// Connect to the "server".
		sockaddr_in sa{};
		InetPton(AF_INET, L"192.168.43.102", &sa.sin_addr);
		sa.sin_family= AF_INET;
		sa.sin_port= htons(50537);
		if(connect(clientSocket, reinterpret_cast<sockaddr*>(&sa), sizeof(sa)) != SOCKET_ERROR) {
			// Start the server authentication flow (flow one).
			TwitchInGames::ServerAuth serverAuth;
			TwitchInGames::tstring state;
			auto task= serverAuth.StartAuth(clientId, redirectUri, { L"user:read:email" }, state);

			// Send the state to the "server".  It will use it to validate the
			// Twitch server authentication response.
			send(clientSocket, reinterpret_cast<char const*>(state.data()),
				static_cast<int>(state.size() * sizeof(state[0])), 0);
			shutdown(clientSocket, SD_SEND);

			// Receive the access and refresh tokens from the "server".
			char buffer[888];
			auto n= recv(clientSocket, buffer, sizeof(buffer), 0);
			std::wstring s(buffer, buffer + n / sizeof(buffer[0]));
			auto i= s.find(L'\t');
			TwitchInGames::tstring accessToken(s.cbegin(), s.cbegin() + i);
			TwitchInGames::tstring refreshToken(s.cbegin() + i + 1, s.cend());

			// Complete the server authentication by setting the tokens.
			serverAuth.Finish(accessToken.c_str(), refreshToken.c_str());
			token= task.get().c_str();
		} else {
			token= L"Cannot connect";
		}
		closesocket(clientSocket);
	}
	return token;
}
