// Path: library/src/main/java/com/pokegoapi/exceptions/request/InvalidCredentialsException.java
// public class InvalidCredentialsException extends RequestFailedException {
// 	public InvalidCredentialsException() {
// 		super();
// 	}
// 
// 	public InvalidCredentialsException(String reason) {
// 		super(reason);
// 	}
// 
// 	public InvalidCredentialsException(Throwable exception) {
// 		super(exception);
// 	}
// 
// 	public InvalidCredentialsException(String reason, Throwable exception) {
// 		super(reason, exception);
// 	}
// }


import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import com.pokegoapi.exceptions.request.InvalidCredentialsException;
import com.pokegoapi.exceptions.request.LoginFailedException;
import com.pokegoapi.util.Log;
import com.pokegoapi.util.SystemTimeImpl;
import com.pokegoapi.util.Time;
import com.squareup.moshi.Moshi;
import lombok.Getter;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import java.io.IOException;
/*
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.pokegoapi.auth;



/**
 * @deprecated Use {@link GoogleAutoCredentialProvider}
 */
@Deprecated
public class GoogleUserCredentialProvider extends CredentialProvider {

	public static final String SECRET = "NCjF1TLi2CcY6t5mt0ZveuL7";
	public static final String CLIENT_ID = "848232511240-73ri3t7plvk96pj4f85uj8otdat2alem.apps.googleusercontent.com";
	public static final String OAUTH_TOKEN_ENDPOINT = "https://www.googleapis.com/oauth2/v4/token";
	public static final String LOGIN_URL = "https://accounts.google"
			+ ".com/o/oauth2/auth?client_id=848232511240-73ri3t7plvk96pj4f85uj8otdat2alem.apps.googleusercontent"
			+ ".com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=openid%20email%20https"
			+ "%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email";
	private static final String TAG = GoogleUserCredentialProvider.class.getSimpleName();
	//We try and refresh token 5 minutes before it actually expires
	protected static final long REFRESH_TOKEN_BUFFER_TIME = 5 * 60 * 1000;
	protected final OkHttpClient client;

	protected final Time time;

	protected long expiresTimestamp;

	protected String tokenId;

	@Getter
	public String refreshToken;

	protected AuthInfo.Builder authbuilder;

	/**
	 * Used for logging in when one has a persisted refreshToken.
	 *
	 * @param client OkHttp client
	 * @param refreshToken Refresh Token Persisted by user
	 * @param time a Time implementation
	 * @throws LoginFailedException if an exception occurs while attempting to log in
	 * @throws InvalidCredentialsException if invalid credentials are used
	 */
	public GoogleUserCredentialProvider(OkHttpClient client, String refreshToken, Time time)
// Path: library/src/main/java/com/pokegoapi/exceptions/request/InvalidCredentialsException.java
// public class InvalidCredentialsException extends RequestFailedException {
// 	public InvalidCredentialsException() {
// 		super();
// 	}
// 
// 	public InvalidCredentialsException(String reason) {
// 		super(reason);
// 	}
// 
// 	public InvalidCredentialsException(Throwable exception) {
// 		super(exception);
// 	}
// 
// 	public InvalidCredentialsException(String reason, Throwable exception) {
// 		super(reason, exception);
// 	}
// }


// Path: library/src/main/java/com/pokegoapi/auth/GoogleUserCredentialProvider.java
import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo;
import com.pokegoapi.exceptions.request.InvalidCredentialsException;
import com.pokegoapi.exceptions.request.LoginFailedException;
import com.pokegoapi.util.Log;
import com.pokegoapi.util.SystemTimeImpl;
import com.pokegoapi.util.Time;
import com.squareup.moshi.Moshi;
import lombok.Getter;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import java.io.IOException;

/*
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.pokegoapi.auth;



/**
 * @deprecated Use {@link GoogleAutoCredentialProvider}
 */
@Deprecated
public class GoogleUserCredentialProvider extends CredentialProvider {

	public static final String SECRET = "NCjF1TLi2CcY6t5mt0ZveuL7";
	public static final String CLIENT_ID = "848232511240-73ri3t7plvk96pj4f85uj8otdat2alem.apps.googleusercontent.com";
	public static final String OAUTH_TOKEN_ENDPOINT = "https://www.googleapis.com/oauth2/v4/token";
	public static final String LOGIN_URL = "https://accounts.google"
			+ ".com/o/oauth2/auth?client_id=848232511240-73ri3t7plvk96pj4f85uj8otdat2alem.apps.googleusercontent"
			+ ".com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=openid%20email%20https"
			+ "%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email";
	private static final String TAG = GoogleUserCredentialProvider.class.getSimpleName();
	//We try and refresh token 5 minutes before it actually expires
	protected static final long REFRESH_TOKEN_BUFFER_TIME = 5 * 60 * 1000;
	protected final OkHttpClient client;

	protected final Time time;

	protected long expiresTimestamp;

	protected String tokenId;

	@Getter
	public String refreshToken;

	protected AuthInfo.Builder authbuilder;

	/**
	 * Used for logging in when one has a persisted refreshToken.
	 *
	 * @param client OkHttp client
	 * @param refreshToken Refresh Token Persisted by user
	 * @param time a Time implementation
	 * @throws LoginFailedException if an exception occurs while attempting to log in
	 * @throws InvalidCredentialsException if invalid credentials are used
	 */
	public GoogleUserCredentialProvider(OkHttpClient client, String refreshToken, Time time)
			throws LoginFailedException, InvalidCredentialsException {