2 * Copyright (c) 2010-2021 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.openhab.binding.tado.internal.api.auth.Authorizer;
16 import org.openhab.binding.tado.internal.api.auth.OAuthAuthorizer;
17 import org.openhab.binding.tado.internal.api.client.HomeApi;
19 import com.google.gson.Gson;
22 * Factory to create and configure {@link HomeApi} instances.
24 * @author Dennis Frommknecht - Initial contribution
26 public class HomeApiFactory {
27 private static final String OAUTH_SCOPE = "home.user";
28 private static final String OAUTH_CLIENT_ID = "public-api-preview";
29 private static final String OAUTH_CLIENT_SECRET = "4HJGRffVR8xb3XdEUQpjgZ1VplJi6Xgw";
31 public HomeApi create(String username, String password) {
32 Gson gson = GsonBuilderFactory.defaultGsonBuilder().create();
33 Authorizer authorizer = new OAuthAuthorizer().passwordFlow(username, password).clientId(OAUTH_CLIENT_ID)
34 .clientSecret(OAUTH_CLIENT_SECRET).scopes(OAUTH_SCOPE);
35 return new HomeApi(gson, authorizer);