public class OAuth4Code {
public static void main(String [] args) throws WeiboException, IOException{
Oauth oauth = new Oauth();
BareBonesBrowserLaunch.openURL(oauth.authorize("code"));
System.out.println(oauth.authorize("code"));//
System.out.println("Hit enter when it's done.[Enter]:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hit enter when it's done ###.[Enter]:"); String code = br.readLine();
Log.logInfo("code: " + code);
try{
System.out.println(oauth.getAccessTokenByCode(code));
} catch (WeiboException e) {
if(401 == e.getStatusCode()){
Log.logInfo("Unable to get the access token.");
}else{
e.printStackTrace();
}
}
}}是一段OUATH2认证的SDK中的代码,System.out.println(oauth.authorize("code"))输出为https://api.weibo.com/oauth2/authorize?client_id=&redirect_uri=&response_type=code 我想问的是为什么String code = br.readLine(); 这行可以读出CODE呢BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
这行不是等控制台输入么?控制台要输入CODE么?还是自动会导入CODE?
public static void main(String [] args) throws WeiboException, IOException{
Oauth oauth = new Oauth();
BareBonesBrowserLaunch.openURL(oauth.authorize("code"));
System.out.println(oauth.authorize("code"));//
System.out.println("Hit enter when it's done.[Enter]:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hit enter when it's done ###.[Enter]:"); String code = br.readLine();
Log.logInfo("code: " + code);
try{
System.out.println(oauth.getAccessTokenByCode(code));
} catch (WeiboException e) {
if(401 == e.getStatusCode()){
Log.logInfo("Unable to get the access token.");
}else{
e.printStackTrace();
}
}
}}是一段OUATH2认证的SDK中的代码,System.out.println(oauth.authorize("code"))输出为https://api.weibo.com/oauth2/authorize?client_id=&redirect_uri=&response_type=code 我想问的是为什么String code = br.readLine(); 这行可以读出CODE呢BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
这行不是等控制台输入么?控制台要输入CODE么?还是自动会导入CODE?
解决方案 »
- c++和java的内存分配到底是怎么回事
- 关于Socket的问题
- JTextField tf = new JTextField();怎么在其他类中给tf对象赋值替换掉原来的值?最好举个例子分析一下。
- java参数里,NewSize如果不配置的话,是根据XMS值以及年轻、年老代的默认比率来决定年轻代的大小吗?
- javascript 弹出窗口问题,高手帮忙解释一下各个语句的含义
- 关于一对多的保存问题
- java中的异常处理若干问题很疑惑,可以来深入分析一下
- 怎样引用集合元素?
- *.mvr文件是个什么东西?
- java java.lang.ClassNotFoundException 在线等
- 基于JavaNIO长连接的聊天室。
- 关于java 多线程的问题
这个是监听 控制台的代码,相当于出控制台读出数据。