2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.tado.internal.api;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.tado.internal.api.auth.Authorizer;
17 import org.openhab.binding.tado.internal.api.auth.OAuthAuthorizer;
18 import org.openhab.binding.tado.internal.api.client.HomeApi;
20 import com.google.gson.Gson;
23 * Factory to create and configure {@link HomeApi} instances.
25 * @author Dennis Frommknecht - Initial contribution
28 public class HomeApiFactory {
29 private static final String OAUTH_SCOPE = "home.user";
30 private static final String OAUTH_CLIENT_ID = "public-api-preview";
31 private static final String OAUTH_CLIENT_SECRET = "4HJGRffVR8xb3XdEUQpjgZ1VplJi6Xgw";
33 public HomeApi create(String username, String password) {
34 Gson gson = GsonBuilderFactory.defaultGsonBuilder().create();
35 Authorizer authorizer = new OAuthAuthorizer().passwordFlow(username, password).clientId(OAUTH_CLIENT_ID)
36 .clientSecret(OAUTH_CLIENT_SECRET).scopes(OAUTH_SCOPE);
37 return new HomeApi(gson, authorizer);