Package com.dongxuexidu.douban4j.model.app

Examples of com.dongxuexidu.douban4j.model.app.AccessToken


      System.out.println(oauth.getGetCodeRedirectUrl());
      System.out.print("Put the code you got here.[Enter]:");
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String code = br.readLine();
      System.out.println("code : " + code);
      AccessToken at = oauth.tradeAccessTokenWithCode(code);
      System.out.println("at : " + at.getAccessToken());
      System.out.println("uid : " + at.getDoubanUserId());
      return at.getAccessToken();
    } catch (DoubanException ex) {
      Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex);
      return null;
    } catch (IOException ex) {
      Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here


      throw ErrorHandler.cannotGetAccessToken();
    }
    System.out.println("got result !");
    System.out.println(responseStr);
    JSONObject jObj = Converters.toJsonObj(responseStr);
    AccessToken token = new AccessToken();
    if (jObj.containsKey("access_token")) {
      String accessToken = jObj.getString("access_token");
      token.setAccessToken(accessToken);
    } else {
      throw ErrorHandler.cannotGetAccessToken();
    }
    if (jObj.containsKey("expires_in")) {
      int expiresIn = jObj.getInt("expires_in");
      token.setExpiresIn(expiresIn);
    } else {
      throw ErrorHandler.cannotGetAccessToken();
    }
    if (jObj.containsKey("refresh_token")) {
      String refreshToken = jObj.getString("refresh_token");
      token.setRefreshToken(refreshToken);
    }
    if (jObj.containsKey("douban_user_id")) {
      String doubanUserId = jObj.getString("douban_user_id");
      token.setDoubanUserId(doubanUserId);
    }
    return token;
  }
View Full Code Here

TOP

Related Classes of com.dongxuexidu.douban4j.model.app.AccessToken

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.