本文整理汇总了Java中org.scribe.oauth.OAuthService.getAuthorizationUrl方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthService.getAuthorizationUrl方法的具体用法?Java OAuthService.getAuthorizationUrl怎么用?Java OAuthService.getAuthorizationUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.scribe.oauth.OAuthService
的用法示例。
在下文中一共展示了OAuthService.getAuthorizationUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: redirectUserToGrantAccess
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
protected String redirectUserToGrantAccess()
{
try
{
OAuthService service = createOAuthScribeService();
Token requestToken = service.getRequestToken();
String authUrl = service.getAuthorizationUrl(requestToken);
request.getSession().setAttribute("requestToken", requestToken);
return SystemUtils.getRedirect(this, authUrl, true);
} catch (Exception e)
{
addErrorMessage("Cannot proceed authentication, check OAuth credentials for account " + getOrganizationName());
return INPUT;
}
}
示例2: redirectUserToBitbucket
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private String redirectUserToBitbucket()
{
try
{
OAuthService service = createOAuthScribeService();
Token requestToken = service.getRequestToken();
String authUrl = service.getAuthorizationUrl(requestToken);
request.getSession().setAttribute(SESSION_KEY_REQUEST_TOKEN, requestToken);
return SystemUtils.getRedirect(this, authUrl, true);
}
catch (Exception e)
{
log.warn("Error redirect user to bitbucket server.", e);
addErrorMessage("The authentication with Bitbucket has failed. Please check your OAuth settings.");
triggerAddFailedEvent(FAILED_REASON_OAUTH_TOKEN);
return INPUT;
}
}
示例3: oAuth
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private void oAuth() {
// Replace these with your own api key and secret
OAuthService service = FlickrForPalabreApplication.getoAuthService();
Token mRequestToken = FlickrForPalabreApplication.getRequestToken();
if (mRequestToken == null) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, getString(R.string.oauth_connection_error), Toast.LENGTH_LONG).show();
}
});
return;
}
final String authorizationUrl = service.getAuthorizationUrl(mRequestToken);
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(MainActivity.this).edit();
editor.putString(SharedPreferenceKeys.TOKEN_TOKEN, mRequestToken.getToken())
.putString(SharedPreferenceKeys.TOKEN_SECRET, mRequestToken.getSecret())
.putString(SharedPreferenceKeys.TOKEN_RESPONSE, mRequestToken.getRawResponse())
.apply();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authorizationUrl)));
}
示例4: doRequestAuth
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private TwitterAuthDoneEvent doRequestAuth()
{
Token token = null;
String authUrl = null;
try
{
OAuthService service = new ServiceBuilder()
.provider( TwitterApi.SSL.class )
.callback( TwitterLoginActivity.TWITTER_CALLBACK_URL )
.apiKey( TwitterConfig.TWITTER_OAUTH_CONSUMER_KEY )
.apiSecret( TwitterConfig.TWITTER_OAUTH_CONSUMER_SECRET )
.build();
token = service.getRequestToken();
authUrl = service.getAuthorizationUrl( token );
}
catch ( OAuthConnectionException e )
{
Helper.debug( "Error while obtaining twitter request token : " + e.getMessage() );
}
boolean success = null != token;
return new TwitterAuthDoneEvent( success, token, null, authUrl, AuthType.REQUEST );
}
示例5: authorize
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private Token authorize() {
OAuthService service = new ServiceBuilder()
.provider(CubeSensorsAuthApi.class)
.apiKey(CubeSensorsProperties.getAppKey())
.apiSecret(CubeSensorsProperties.getAppSecret())
.signatureType(SignatureType.QueryString).build();
Token requestToken = service.getRequestToken();
String authorizationUrl = service.getAuthorizationUrl(requestToken);
String authorization = authProvider.getAuthorization(authorizationUrl);
Token accessToken = service.getAccessToken(requestToken, new Verifier(
authorization));
return accessToken;
}
示例6: sendForAuthorization
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private void sendForAuthorization(HttpServletRequest request, HttpServletResponse response, OAuthService service) {
String retUrl = (String) request.getAttribute("javax.servlet.forward.request_uri");
if (request.getSession().getAttribute("OAUTH_REDIRECT") != null) {
retUrl = (String) request.getSession().getAttribute("OAUTH_REDIRECT");
}
if (request.getParameter("referrer") != null) {
retUrl = request.getParameter("referrer");
}
request.getSession().setAttribute("OAUTH_REDIRECT", retUrl);
String authorizationUrl = service.getAuthorizationUrl(null);
response.reset();
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", authorizationUrl);
return;
}
示例7: getToken
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Background
public void getToken() {
final String apiKey = getString(R.string.api_key);
final String apiSecret = getString(R.string.api_secret);
final String callback = getString(R.string.api_callback);
final OAuthService service = new ServiceBuilder()
.provider(new RavelryApi(getString(R.string.ravelry_oauth_url)))
.apiKey(apiKey).apiSecret(apiSecret).callback(callback).build();
final Token requestToken;
try {
requestToken = service.getRequestToken();
} catch (Exception e) {
AQUtility.report(e);
moveTaskToBack(true);
return;
}
final String authURL = service.getAuthorizationUrl(requestToken);
callAuthPage(callback, service, requestToken, authURL);
}
示例8: main
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Paste the consumerKey here");
System.out.print(">>");
String apiKey = in.nextLine();
System.out.println("Paste the consumerSecret here");
System.out.print(">>");
String apiSecret = in.nextLine();
OAuthService service = new ServiceBuilder()
.provider(YammerApi.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.build();
String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
System.out
.println("Go and authorize your app here (eg. in a web browser):");
System.out.println(authorizationUrl);
System.out.println("... and paste the authorization code here");
System.out.print(">>");
Verifier verifier = new Verifier(in.nextLine());
System.out.println();
Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
System.out.println("Your Access Token is: " + accessToken);
System.out.println();
in.close();
}
示例9: loginURL
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private String loginURL(@NonNull String redirectURL) {
Preconditions.checkArgument(redirectURL.startsWith("/"));
OAuthService service = new ServiceBuilder()
.provider(FacebookApi.class)
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(host + redirectURL)
.scope("email")
.build();
return service.getAuthorizationUrl(null);
}
示例10: getAuthUrl
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Override
public Response getAuthUrl(long customerId, int clientId) {
if (!IdPool.clientInList(customerId, clientId)) {
clientNotFoundMsg.setCustomerId(customerId);
clientNotFoundMsg.setClientId(clientId);
return Response.status(Response.Status.OK).entity(clientNotFoundMsg).type(MediaType.APPLICATION_JSON_TYPE).build();
}
customer = LinkedInCustomerResource.getCustomerList().get(customerId);
client = customer.getClientDB().getClientList().get(clientId);
AuthUrlMsg msg = new AuthUrlMsg();
msg.setCustomerId(customerId);
msg.setClientId(clientId);
msg.setLinkStatus(client.getStatus());
if (client.getLinkHandler().getRequestAuthUrl() == null) {
OAuthService serviceProvider = new ServiceBuilder().provider(LinkedInApi.class).apiKey(API_KEY).apiSecret(API_SECRET).build();
// pass the serviceProvider obj to LinkHandler
client.getLinkHandler().setServiceProvider(serviceProvider);
//to get request token
requestToken = serviceProvider.getRequestToken();
client.getLinkHandler().setRequestToken(requestToken);
// use request token to get auth url
requestAuthUrl = serviceProvider.getAuthorizationUrl(requestToken);
client.getLinkHandler().setRequestAuthUrl(requestAuthUrl);
msg.setRequestUrl(requestAuthUrl);
return Response.status(Response.Status.OK).entity(msg).type(MediaType.APPLICATION_JSON_TYPE).build();
} else {
return Response.status(Response.Status.OK).entity(msg).type(MediaType.APPLICATION_JSON_TYPE).build();
}
}
示例11: authorize
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Test
@Ignore("Not suitable as automatic unit test. Requires manual action.")
public void authorize() throws URISyntaxException, IOException {
final String key = System.getProperty("key");
final String secret = System.getProperty("secret");
assertNotNull("You must use a discogs key via System property -Dkey=", key);
assertNotNull("You must use a discogs secret via System property -Dsecret=", secret);
assertNotNull("You must use a custom user agent via System property -Dhttp.agent=", System.getProperty("http.agent"));
final OAuthService service = new ServiceBuilder()
.provider(DiscogsApi.class)
.apiKey(key)
.apiSecret(secret)
.debug()
.build();
final Token requestToken = service.getRequestToken();
System.out.println("Token: " + requestToken);
final String authorizationUrl = service.getAuthorizationUrl(requestToken);
System.out.println("AuthorizationUrl: " + authorizationUrl);
Desktop.getDesktop().browse(new URI(authorizationUrl));
System.out.println("Please enter token: ");
final String token = System.console().readLine();
System.out.println("Got " + token);
final Verifier verifier = new Verifier(token);
// Trade the Request Token and Verifier for the Access Token
final Token accessToken = service.getAccessToken(requestToken, verifier);
final OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.discogs.com/image/R-944131-1175701834.jpeg");
service.signRequest(accessToken, request);
final Response response = request.send();
System.out.println(response.getCode() + " " + response.getMessage());
}
示例12: testInstagram
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
@Test
public void testInstagram()
{
OAuthService service = new ServiceBuilder()
.provider(Instagram2Api.class)
.apiKey(OurOAuthParams.INSTAGRAM_API_KEY)
.apiSecret(OurOAuthParams.INSTAGRAM_API_SECRET)
.callback(ClientUtils.getCallbackUrl())
.build();
Token requestToken = null;
String authorizationUrl = service.getAuthorizationUrl(requestToken);
logger.info("authorization url: " + authorizationUrl);
}
示例13: login
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private static void login() {
try {
fos = new FileOutputStream(JasauFileHelper.getSaveDirectory(JasauFileHelper.savePrefix, "OutputTemp"));
} catch (IOException e) {
e.printStackTrace();
}
OAuthService service = new ServiceBuilder().provider(TumblrApi.class).apiKey(ConsumerKey).apiSecret(ConsumerSecret).callback("http://127.0.0.1").debugStream(fos).build();
Token requestToken = service.getRequestToken();
String authUrl = service.getAuthorizationUrl(requestToken);
try {
Desktop.getDesktop().browse(new URI(authUrl));
} catch (IOException | URISyntaxException e1) {
e1.printStackTrace();
}
try {
JasauFileHelper.readFromTempFile();
} catch (IOException e2) {
e2.printStackTrace();
}
try {
JasauFileHelper.writeTokenToFile();
} catch (IOException e3) {
e3.printStackTrace();
}
setClientToken();
}
示例14: auth
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
public String auth(final Shell shell) throws MalformedURLException, InterruptedException {
try {
Class<? extends EvernoteApi> apiClass = EvernoteUtil.brand().scribeOAuthApi();
OAuthService service = new ServiceBuilder().provider(apiClass).apiKey(CONSUMER_KEY).apiSecret(EncryptionUtil.decrypt(CONSUMER_SECRET)).callback(callback.getCallbackURL()).build();
Token requestToken = service.getRequestToken();
String authUrl = service.getAuthorizationUrl(requestToken);
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(authUrl));
} catch (PartInitException couldNotOpenBrowser) {
LinkedHashMap<String, String> btns = MapUtil.orderedMap();
btns.put(Constants.Plugin_OAuth_Copy, Messages.Plugin_OAuth_Copy);
btns.put(Constants.Plugin_OAuth_Cancel, Messages.Plugin_OAuth_Cancel);
String opt = new SyncEclipseUtil().openCustomImageTypeWithCustomButtonsSyncly(shell, Messages.Plugin_OAuth_Title, Messages.Plugin_OAuth_DoItManually, new Image(Display.getDefault(), getClass().getClassLoader().getResourceAsStream(Constants.OAUTH_EVERNOTE_TRADEMARK)), btns);
if (Constants.Plugin_OAuth_Copy.equals(opt)) {
ClipboardUtil.copy(authUrl);
} else {
return StringUtils.EMPTY;
}
}
// wait for callback handling
synchronized (callback) {
callback.wait(30 * 60 * 1000);// 30 minutes
}
String verifierValue = callback.getVerifier();
if (StringUtils.isBlank(verifierValue)) {
return StringUtils.EMPTY;
}
Verifier verifier = new Verifier(verifierValue);
Token accessToken = service.getAccessToken(requestToken, verifier);
return accessToken.getToken();
} finally {
callback.done();
}
}
示例15: initiatingAuthentication
import org.scribe.oauth.OAuthService; //导入方法依赖的package包/类
private void initiatingAuthentication(HttpServletRequest request, HttpServletResponse response,
HttpSession session, OAuthService service) throws IOException {
LOG.info(LOG_MESSAGE_AUTH_INITIATING, new Object[] { request.getRemoteAddr() });
session.setAttribute(ENTRY_URL, request.getRequestURL());
// The request token doesn't matter for OAuth 2.0 which is why it's null
String authUrl = service.getAuthorizationUrl(null);
response.sendRedirect(authUrl);
}