Package com.baasbox.service.sociallogin

Examples of com.baasbox.service.sociallogin.SocialLoginService


    String keyFormat = socialNetwork.toUpperCase()+"_ENABLED";
    Boolean enabled = SocialLoginConfiguration.valueOf(keyFormat).getValueAsBoolean();
    if(enabled==null || enabled == false){
      return badRequest("Social login for "+socialNetwork+" is not enabled");
    }else{
      SocialLoginService sc = SocialLoginService.by(socialNetwork,(String)ctx().args.get("appcode"));
      return ok("{\"url\":\""+sc.getAuthorizationURL(session())+"\"}");
    }
  }
View Full Code Here


   * @param socialNetwork
   * @return
   */
  public static Result callback(String socialNetwork){
    try{
      SocialLoginService sc = SocialLoginService.by(socialNetwork,(String)ctx().args.get("appcode"));
      Token t = sc.requestAccessToken(request(),session());
      return ok("{\""+OAUTH_TOKEN+"\":\""+t.getToken()+"\",\""+OAUTH_SECRET+"\":\""+t.getSecret()+"\"}");
    }catch (UnsupportedSocialNetworkException e){
      return badRequest(e.getMessage());
    }catch (java.lang.IllegalArgumentException e){
      return badRequest(e.getMessage());
View Full Code Here

  public static Result loginWith(String socialNetwork){
   

    String appcode = (String)ctx().args.get("appcode");
    //after this call, db connection is lost!
    SocialLoginService sc = SocialLoginService.by(socialNetwork,appcode);
    Token t =extractOAuthTokensFromRequest(request());
    if(t==null){
      return badRequest(String.format("Both %s and %s should be specified as query parameters or in the json body",OAUTH_TOKEN,OAUTH_SECRET));
    }
    UserInfo result=null;
    try {
      if(sc.validationRequest(t.getToken())){
        result = sc.getUserInfo(t);
      }else{
        return badRequest("Provided token is not valid");
      }
    } catch (BaasBoxSocialException e1) {
      return badRequest(e1.getError());
View Full Code Here

    if(t==null){
      return badRequest("Both '"+OAUTH_TOKEN+"' and '"+OAUTH_SECRET+"' should be specified.");
    }

    String appcode = (String)ctx().args.get("appcode");
    SocialLoginService sc = SocialLoginService.by(socialNetwork,appcode);
   
    UserInfo result=null;
    try {
      if(sc.validationRequest(t.getToken())){
        result = sc.getUserInfo(t);
      }else{
        return badRequest("Provided token is not valid.");
      }
    } catch (BaasBoxSocialException e1) {
      return badRequest(e1.getError());
View Full Code Here

TOP

Related Classes of com.baasbox.service.sociallogin.SocialLoginService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.