本文整理汇总了Java中net.oauth.OAuth.OAUTH_CONSUMER_KEY属性的典型用法代码示例。如果您正苦于以下问题:Java OAuth.OAUTH_CONSUMER_KEY属性的具体用法?Java OAuth.OAUTH_CONSUMER_KEY怎么用?Java OAuth.OAUTH_CONSUMER_KEY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.oauth.OAuth
的用法示例。
在下文中一共展示了OAuth.OAUTH_CONSUMER_KEY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerMessagingServiceScopes
public void registerMessagingServiceScopes(String consumerKey, String scope) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerScopesRegistrationURL);
String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
Invocation.Builder builder = target.request();
builder.header("Authorization", "Basic " + base64Credentials);
Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
form.param("xoauth_scope", scope);
form.param("xoauth_permission", "sendMessages");
Response response = null;
try {
response = builder.post(Entity.form(form));
if (HttpResponseCodes.SC_OK != response.getStatus()) {
throw new RuntimeException("Scopes can not be registered");
}
} finally {
response.close();
}
}
示例2: getSharedSecret
public String getSharedSecret(String consumerKey) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
Invocation.Builder builder = target.request();
Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
Entity<Form> formEntity = Entity.form(form);
Response response = builder.post(formEntity);
if (HttpResponseCodes.SC_OK != response.getStatus()) {
response.close();
throw new RuntimeException("Registration failed");
}
// check that we got all tokens
Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
String secret = tokens.get("xoauth_consumer_secret");
if (secret == null) {
throw new RuntimeException("No secret available");
}
return secret;
}
示例3: registerMessagingServiceScopes
public void registerMessagingServiceScopes(String consumerKey, String scope) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerScopesRegistrationURL);
Invocation.Builder builder = target.request();
builder.header("Authorization", "OpenId " + SubscriberOpenIdIdentifier);
Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
form.param("xoauth_scope", scope);
form.param("xoauth_permission", "sendMessages");
Response response = builder.post(Entity.form(form));
response.close();
if (HttpResponseCodes.SC_OK != response.getStatus()) {
throw new RuntimeException("Scopes can not be registered");
}
}
示例4: generateOAuthHeader
private StringTokenizer generateOAuthHeader(String address) {
return new StringTokenizer("OAuth " + OAuth.OAUTH_CONSUMER_KEY + "=\"" + address + "\"", "");
}