本文整理汇总了Java中com.github.scribejava.apis.FacebookApi类的典型用法代码示例。如果您正苦于以下问题:Java FacebookApi类的具体用法?Java FacebookApi怎么用?Java FacebookApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FacebookApi类属于com.github.scribejava.apis包,在下文中一共展示了FacebookApi类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
public static void main (String[] args) {
ResourceBundle secrets = ResourceBundle.getBundle("facebookutil/secret");
final OAuth20Service service = new ServiceBuilder()
.apiKey(secrets.getString("clientId"))
.apiSecret(secrets.getString("clientSecret"))
.callback("https://duke.edu/")
.grantType("client_credentials")
.build(FacebookApi.instance());
String url = "https://graph.facebook.com/oauth/access_token?";
url = url + "&client_id" + "=" + secrets.getString("clientId");
url = url + "&client_secret" + "=" + secrets.getString("clientSecret");
url = url + "&grant_type" + "=" + "client_credentials";
final OAuthRequest request =
new OAuthRequest(Verb.GET, url, service);
service.signRequest(new OAuth2AccessToken(""), request);
System.out.println(request.getBodyContents());
System.out.println(request.getUrl());
Response response = request.send();
System.out.println(response.getBody());
}
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:TestAppLogin.java
示例2: facebookExample
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
public void facebookExample () {
// Replace these with your client id and secret
final String clientId = mySecrets.getString("facebookId");
final String clientSecret = mySecrets.getString("facebookSecret");
service = new ServiceBuilder()
.apiKey(clientId)
.apiSecret(clientSecret)
.callback(CALLBACK_URL)
// .grantType("client_credentials")
.scope("publish_actions,email,public_profile")
// .scope("publish_actions")
.build(FacebookApi.instance());
System.out.println();
// Obtain the Authorization URL
System.out.println("Fetching the Authorization URL...");
final String authorizationUrl = service.getAuthorizationUrl();
myPage.getEngine().load(authorizationUrl);
}
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:BrowserView.java
示例3: clientInit
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
@Override
protected void clientInit(final AsyncWebContext context) {
CommonHelper.assertNotBlank("fields", this.fields);
configuration.setApi(FacebookApi.instance());
configuration.setProfileDefinition(new FacebookProfileDefinition());
configuration.setScope(scope);
configuration.setHasBeenCancelledFactory(ctx -> {
final String error = ctx.getRequestParameter(OAuthCredentialsException.ERROR);
final String errorReason = ctx.getRequestParameter(OAuthCredentialsException.ERROR_REASON);
// user has denied permissions
if ("access_denied".equals(error) && "user_denied".equals(errorReason)) {
return true;
} else {
return false;
}
});
configuration.setWithState(true);
setConfiguration(configuration);
defaultProfileCreator(new AsyncFacebookProfileCreator(configuration));
super.clientInit(context);
}
开发者ID:millross,项目名称:pac4j-async,代码行数:23,代码来源:AsyncFacebookClient.java
示例4: createService
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
private OAuth20Service createService (ResourceBundle secrets) {
return new ServiceBuilder()
.apiKey(secrets.getString("facebookId"))
.apiSecret(secrets.getString("facebookSecret"))
.callback(secrets.getString("callback"))
.grantType("client_credentials")
.build(FacebookApi.instance());
}
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:9,代码来源:FacebookAppLogin.java
示例5: createService
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
/**
* Creates facebook service given client id and secret
*
* @param clientId
* @param clientSecret
* @return
*/
private OAuth20Service createService (String clientId, String clientSecret) {
return new ServiceBuilder().apiKey(clientId)
.apiSecret(clientSecret)
.callback(mySecrets.getString("callback"))
.scope(SCOPE)
.build(FacebookApi.instance());
}
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:15,代码来源:FacebookLogin.java
示例6: handleAuthorization
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
@RequestMapping("/sign-on/facebook")
public String handleAuthorization(HttpServletRequest request) throws IOException {
logger.info("handleAuthorization");
String apiKey = "1130171497015759";
String apiSecret = "d8b49268dacd1e29eca82de8edd88c1c";
String baseUrl = "http://localhost:8080/webapp";
if (EnvironmentContextLoaderListener.env == Environment.TEST) {
apiKey = "1130170237015885";
apiSecret = ConfigHelper.getProperty("facebook.api.secret");
baseUrl = "http://" + request.getServerName();
} else if (EnvironmentContextLoaderListener.env == Environment.PROD) {
apiKey = "1130160227016886";
apiSecret = ConfigHelper.getProperty("facebook.api.secret");
baseUrl = "http://" + request.getServerName();
}
oAuth20Service = new ServiceBuilder()
.apiKey(apiKey)
.apiSecret(apiSecret)
.callback(baseUrl + "/sign-on/facebook/callback")
.scope("email,user_about_me") // https://developers.facebook.com/docs/facebook-login/permissions
.build(FacebookApi.instance());
logger.info("Fetching the Authorization URL...");
String authorizationUrl = oAuth20Service.getAuthorizationUrl();
logger.info("Got the Authorization URL!");
return "redirect:" + authorizationUrl;
}
开发者ID:elimu-ai,项目名称:webapp,代码行数:31,代码来源:SignOnControllerFacebook.java
示例7: facebookService
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
private static OAuth20Service facebookService(
final HashMap cfg,
@Nullable final ReadableMap opts,
final String callbackUrl) {
ServiceBuilder builder = OAuthManagerProviders._oauth2ServiceBuilder(cfg, opts, callbackUrl);
return builder.build(FacebookApi.instance());
}
开发者ID:fullstackreact,项目名称:react-native-oauth,代码行数:8,代码来源:OAuthManagerProviders.java
示例8: createOAuthService
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
/**
* Creates an OAuthService for authentication a user with OAuth
*
* @param oAuthProvider The OAuth provider Enum
* @return An Optional OAuthService
*/
public Optional<OAuthService> createOAuthService(OAuthProvider oAuthProvider) {
Objects.requireNonNull(oAuthProvider, Required.OAUTH_PROVIDER.toString());
Config config = Application.getInstance(Config.class);
OAuthService oAuthService = null;
switch (oAuthProvider) {
case TWITTER:
oAuthService = new ServiceBuilder(config.getString(Key.OAUTH_TWITTER_KEY))
.callback(config.getString(Key.OAUTH_TWITTER_CALLBACK))
.apiSecret(config.getString(Key.OAUTH_TWITTER_SECRET))
.build(TwitterApi.instance());
break;
case GOOGLE:
oAuthService = new ServiceBuilder(config.getString(Key.OAUTH_GOOGLE_KEY))
.scope(SCOPE)
.callback(config.getString(Key.OAUTH_GOOGLE_CALLBACK))
.apiSecret(config.getString(Key.OAUTH_GOOGLE_SECRET))
.state("secret" + new SecureRandom().nextInt(MAX_RANDOM))
.build(GoogleApi20.instance());
break;
case FACEBOOK:
oAuthService = new ServiceBuilder(config.getString(Key.OAUTH_FACEBOOK_KEY))
.callback(config.getString(Key.OAUTH_FACEBOOK_CALLBACK))
.apiSecret(config.getString(Key.OAUTH_FACEBOOK_SECRET))
.build(FacebookApi.instance());
break;
default:
break;
}
return (oAuthService == null) ? Optional.empty() : Optional.of(oAuthService);
}
开发者ID:svenkubiak,项目名称:mangooio,代码行数:39,代码来源:RequestHelper.java
示例9: getApi
import com.github.scribejava.apis.FacebookApi; //导入依赖的package包/类
@Override
protected BaseApi<OAuth20Service> getApi() {
return FacebookApi.instance();
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:5,代码来源:FacebookClient.java
注:本文中的com.github.scribejava.apis.FacebookApi类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论