70 lines
2.2 KiB
Java
70 lines
2.2 KiB
Java
/**
|
|
* Copyright (C) 2017-2018 Christian Pierre MOMON <cmomon@april.org>
|
|
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
|
|
*
|
|
* This file is part of (April) Hebdobot.
|
|
*
|
|
* Hebdobot is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Hebdobot 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 Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with Hebdobot. If not, see <http://www.gnu.org/licenses/>
|
|
*/
|
|
package org.april.hebdobot.identica;
|
|
|
|
import org.scribe.builder.api.DefaultApi10a;
|
|
import org.scribe.model.Token;
|
|
|
|
/**
|
|
* The Class IdentiCaApi.
|
|
*/
|
|
public class IdentiCaApi extends DefaultApi10a
|
|
{
|
|
private static final String IDENTI_CA_OAUTH_API_URL = "https://identi.ca/api/oauth";
|
|
private static final String IDENTI_CA_OAUTH_API_REQUEST_TOKEN_URL = IDENTI_CA_OAUTH_API_URL + "/request_token";
|
|
private static final String IDENTI_CA_OAUTH_API_ACCESS_TOKEN_URL = IDENTI_CA_OAUTH_API_URL + "/access_token";
|
|
private static final String IDENTI_CA_OAUTH_API_AUTHORIZE_URL = IDENTI_CA_OAUTH_API_URL + "/authorize?oauth_token=%s";
|
|
|
|
/**
|
|
* Gets the access token endpoint.
|
|
*
|
|
* @return the access token endpoint
|
|
*/
|
|
@Override
|
|
public String getAccessTokenEndpoint()
|
|
{
|
|
return IDENTI_CA_OAUTH_API_ACCESS_TOKEN_URL;
|
|
}
|
|
|
|
/**
|
|
* Gets the authorization url.
|
|
*
|
|
* @param requestToken
|
|
* the request token
|
|
* @return the authorization url
|
|
*/
|
|
@Override
|
|
public String getAuthorizationUrl(final Token requestToken)
|
|
{
|
|
return String.format(IDENTI_CA_OAUTH_API_AUTHORIZE_URL, requestToken.getToken());
|
|
}
|
|
|
|
/**
|
|
* Gets the request token endpoint.
|
|
*
|
|
* @return the request token endpoint
|
|
*/
|
|
@Override
|
|
public String getRequestTokenEndpoint()
|
|
{
|
|
return IDENTI_CA_OAUTH_API_REQUEST_TOKEN_URL;
|
|
}
|
|
}
|