mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-15 13:02:07 +08:00
SDK update
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
package com.connsec.client.oauth.test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.maxkey.client.oauth.builder.ServiceBuilder;
|
||||
import org.maxkey.client.oauth.builder.api.MaxkeyApi10a;
|
||||
import org.maxkey.client.oauth.model.Token;
|
||||
import org.maxkey.client.oauth.oauth.OAuthService;
|
||||
|
||||
|
||||
public class Connsec10aExample
|
||||
{
|
||||
private static final String PROTECTED_RESOURCE_URL = "http://api.foursquare.com/v1/user";
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
OAuthService service = new ServiceBuilder()
|
||||
.provider(MaxkeyApi10a.class)
|
||||
.apiKey("tonr-consumer-key")
|
||||
.apiSecret("SHHHHH!!!!!!!!!!")
|
||||
.callback(PROTECTED_RESOURCE_URL)
|
||||
.build();
|
||||
Scanner in = new Scanner(System.in);
|
||||
|
||||
System.out.println("=== Foursquare's OAuth Workflow ===");
|
||||
System.out.println();
|
||||
|
||||
// Obtain the Request Token
|
||||
System.out.println("Fetching the Request Token...");
|
||||
Token requestToken = service.getRequestToken();
|
||||
System.out.println("Got the Request Token!");
|
||||
System.out.println();
|
||||
|
||||
System.out.println("Now go and authorize Scribe here:");
|
||||
System.out.println(service.getAuthorizationUrl(requestToken));
|
||||
/* System.out.println("And paste the verifier here");
|
||||
System.out.print(">>");
|
||||
Verifier verifier = new Verifier(in.nextLine());
|
||||
System.out.println();
|
||||
|
||||
Token requestToken =new Token("3f1fe990-6795-4241-911e-ca0357ecab89","");
|
||||
Verifier verifier = new Verifier("w3LGBc");
|
||||
// Trade the Request Token and Verfier for the Access Token
|
||||
System.out.println("Trading the Request Token for an Access Token...");
|
||||
Token accessToken = service.getAccessToken(requestToken, verifier);
|
||||
System.out.println("Got the Access Token!");
|
||||
System.out.println("(if your curious it looks like this: " + accessToken + " )");
|
||||
System.out.println();
|
||||
|
||||
// Now let's go and ask for a protected resource!
|
||||
System.out.println("Now we're going to access a protected resource...");
|
||||
OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
|
||||
service.signRequest(accessToken, request);
|
||||
Response response = request.send();
|
||||
System.out.println("Got it! Lets see what we found...");
|
||||
System.out.println();
|
||||
System.out.println(response.getBody());
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Thats it man! Go and build something awesome with Scribe! :)");
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.connsec.client.oauth.test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.maxkey.client.http.HttpVerb;
|
||||
import org.maxkey.client.http.Response;
|
||||
import org.maxkey.client.oauth.builder.ServiceBuilder;
|
||||
import org.maxkey.client.oauth.builder.api.MaxkeyApi10a;
|
||||
import org.maxkey.client.oauth.model.OAuthRequest;
|
||||
import org.maxkey.client.oauth.model.Token;
|
||||
import org.maxkey.client.oauth.model.Verifier;
|
||||
import org.maxkey.client.oauth.oauth.OAuthService;
|
||||
|
||||
|
||||
public class Connsec10aVerifierExample
|
||||
{
|
||||
private static final String PROTECTED_RESOURCE_URL = "http://api.foursquare.com/v1/user";
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
OAuthService service = new ServiceBuilder()
|
||||
.provider(MaxkeyApi10a.class)
|
||||
.apiKey("tonr-consumer-key")
|
||||
.apiSecret("SHHHHH!!!!!!!!!!")
|
||||
.callback(PROTECTED_RESOURCE_URL)
|
||||
.build();
|
||||
Scanner in = new Scanner(System.in);
|
||||
|
||||
System.out.println("=== Foursquare's OAuth Workflow ===");
|
||||
System.out.println();
|
||||
|
||||
// Obtain the Request Token
|
||||
/* System.out.println("Fetching the Request Token...");
|
||||
Token requestToken = service.getRequestToken();
|
||||
System.out.println("Got the Request Token!");
|
||||
System.out.println();
|
||||
|
||||
System.out.println("Now go and authorize Scribe here:");
|
||||
System.out.println(service.getAuthorizationUrl(requestToken));
|
||||
System.out.println("And paste the verifier here");
|
||||
System.out.print(">>");
|
||||
Verifier verifier = new Verifier(in.nextLine());
|
||||
System.out.println();
|
||||
*/
|
||||
Token requestToken =new Token("d5df60ae-78fa-4a6e-9a66-cd7a84e746ea","");
|
||||
Verifier verifier = new Verifier("MSHAor");
|
||||
// Trade the Request Token and Verfier for the Access Token
|
||||
System.out.println("Trading the Request Token for an Access Token...");
|
||||
Token accessToken = service.getAccessToken(requestToken, verifier);
|
||||
System.out.println("Got the Access Token!");
|
||||
System.out.println("(if your curious it looks like this: " + accessToken + " )");
|
||||
System.out.println();
|
||||
|
||||
// Now let's go and ask for a protected resource!
|
||||
System.out.println("Now we're going to access a protected resource...");
|
||||
OAuthRequest request = new OAuthRequest(HttpVerb.GET, PROTECTED_RESOURCE_URL);
|
||||
service.signRequest(accessToken, request);
|
||||
Response response = request.send();
|
||||
System.out.println("Got it! Lets see what we found...");
|
||||
System.out.println();
|
||||
System.out.println(response.getBody());
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Thats it man! Go and build something awesome with Scribe! :)");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.connsec.client.oauth.test;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class LogerTest {
|
||||
private static Log log = LogFactory.getLog(LogerTest. class );
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
log.info("teset");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.maxkey.client.oauth.model.Token;
|
||||
import org.maxkey.client.oauth.model.Verifier;
|
||||
import org.maxkey.client.oauth.oauth.OAuthService;
|
||||
|
||||
public class Connsec20Example
|
||||
public class MaxKey20Example
|
||||
{
|
||||
private static final String NETWORK_NAME = "SinaWeibo";
|
||||
private static final String PROTECTED_RESOURCE_URL = "https://api.weibo.com/2/account/get_uid.json";
|
||||
@@ -6,7 +6,7 @@ import org.maxkey.client.oauth.model.OAuthConfig;
|
||||
import org.maxkey.client.oauth.model.Token;
|
||||
import org.maxkey.client.oauth.oauth.OAuthPasswordService;
|
||||
|
||||
public class ConnsecPasswordDemo {
|
||||
public class MaxkeyPasswordDemo {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
@@ -16,19 +16,19 @@ public class RestClientTest {
|
||||
|
||||
OAuthClient tokenRestClient=new OAuthClient("https://exmail.qq.com/cgi-bin/token");
|
||||
tokenRestClient.addParameter("grant_type", "client_credentials");
|
||||
tokenRestClient.addBasicAuthorization("connsec", "66199e4c36b6dfcfb6f1ebceda789432");
|
||||
tokenRestClient.addBasicAuthorization("maxkey", "66199e4c36b6dfcfb6f1ebceda789432");
|
||||
Token token =tokenRestClient.requestAccessToken();
|
||||
System.out.println(token);
|
||||
|
||||
OAuthClient authkeyRestClient=new OAuthClient("http://openapi.exmail.qq.com:12211/openapi/mail/authkey");
|
||||
authkeyRestClient.addBearerAuthorization(token.getAccess_token());
|
||||
authkeyRestClient.addParameter("Alias", "test@connsec.com");
|
||||
authkeyRestClient.addParameter("Alias", "test@maxkey.org");
|
||||
|
||||
|
||||
HashMap authKey=JsonUtils.gson2Object(authkeyRestClient.execute().getBody(), HashMap.class);
|
||||
|
||||
String login_url="https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=%s&user=%s&ticket=%s";
|
||||
System.out.println(String.format(login_url, "connsec","test@connsec.com",authKey.get("auth_key")));
|
||||
System.out.println(String.format(login_url, "connsec","test@maxkey.org",authKey.get("auth_key")));
|
||||
//https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=connsec&user=test@connsec.com&ticket=25640C491CA4A056BD1A936C6AA4ABBCAB13AE76EB80E6C3A9259F5E8BFD91D7EA05D10DA3FB18F9BFB445D104CB58A0B4CDE97D9F219F3C
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user