All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.genesys2.client.oauth.api.GenesysApi Maven / Gradle / Ivy

There is a newer version: 3.0
Show newest version
/*
 * Copyright 2016 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.genesys2.client.oauth.api;

import com.github.scribejava.core.builder.api.DefaultApi20;
import com.github.scribejava.core.oauth2.clientauthentication.ClientAuthentication;
import com.github.scribejava.core.oauth2.clientauthentication.RequestBodyAuthenticationScheme;

/**
 * Genesys API v1.
 */
public class GenesysApi extends DefaultApi20 {

	/** OAuth2 authorization endpoint that is appended to {@link #baseUrl}. */
	public static final String AUTHORIZE_ENDPOINT = "/oauth/authorize";

	/** OAuth2 access token endpoint that is appended to {@link #baseUrl}. */
	private static final String TOKEN_ENDPOINT = "/oauth/token";

	/** The base URL of the Genesys server (e.g. https://www.genesys-pgr.org) */
	private final String baseUrl;

	public GenesysApi(String baseUrl) {
		this.baseUrl = baseUrl;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.scribe.builder.api.DefaultApi20#getAccessTokenEndpoint()
	 */
	@Override
	public String getAccessTokenEndpoint() {
		return this.baseUrl + TOKEN_ENDPOINT;
	}

	@Override
	protected String getAuthorizationBaseUrl() {
		return baseUrl + AUTHORIZE_ENDPOINT;
	}

	/**
	 * Gets the base url.
	 *
	 * @return the base url
	 */
	public String getBaseUrl() {
		return baseUrl;
	}

	@Override
	public ClientAuthentication getClientAuthentication() {
		return RequestBodyAuthenticationScheme.instance();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy