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.easee.internal.command.account;
15 import static org.openhab.binding.easee.internal.EaseeBindingConstants.REFRESH_TOKEN_URL;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jetty.client.api.Request;
19 import org.eclipse.jetty.client.util.StringContentProvider;
20 import org.eclipse.jetty.http.HttpMethod;
21 import org.openhab.binding.easee.internal.handler.EaseeBridgeHandler;
24 * implements the refresh of the access token.
26 * @author Alexander Friese - initial contribution
29 public class RefreshToken extends Login {
32 final String accessToken;
33 final String refreshToken;
35 public RefreshData(String accessToken, String refreshToken) {
36 this.accessToken = accessToken;
37 this.refreshToken = refreshToken;
41 private final RefreshData refreshData;
43 public RefreshToken(EaseeBridgeHandler handler, String accessToken, String refreshToken) {
45 refreshData = new RefreshData(accessToken, refreshToken);
49 protected Request prepareRequest(Request requestToPrepare) {
50 StringContentProvider cp = new StringContentProvider(gson.toJson(refreshData));
51 requestToPrepare.content(cp);
52 requestToPrepare.method(HttpMethod.POST);
54 return requestToPrepare;
58 protected String getURL() {
59 return REFRESH_TOKEN_URL;