Skip to content

Instantly share code, notes, and snippets.

webApp.setWar(warPath.getAbsolutePath());
File warTempDirectory = new File(conf.getString(ConfVars.ZEPPELIN_WAR_TEMPDIR));
warTempDirectory.mkdir();
LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
webApp.setTempDirectory(warTempDirectory);
//xml 파싱
DocumentBuilderFactory docbuildFact = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuild = docbuildFact.newDocumentBuilder();
Document doc = docBuild.parse(is);
doc.getDocumentElement().normalize();
//response
NodeList responseNaver = doc.getElementsByTagName("response");
Node responseNode = responseNaver.item(0);
Element responseElement = (Element) responseNode;
//이메일 가져오기
String json = ReadUrl.readUrl("https://nid.naver.com/oauth2.0/token?client_id=YOURCLIENTID&client_secret=YOURCLIENTSECRET&grant_type=authorization_code&state=YOURSTATETOKEN&code=AUTHORIZATIONCODE");
JSONObject jsonObj = null;
jsonObj = (JSONObject) JSONValue.parse(json);
AccessToken accessToken = new AccessToken(jsonObj.get("access_token").toString(), jsonObj.get("refresh_token").toString(), jsonObj.get("token_type").toString(), jsonObj.get("expires_in").toString());
HttpTransport transport = new NetHttpTransport();
//google-oauth-java-client
Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken.getAccessToken());
HttpRequestFactory requestFactory = transport.createRequestFactory(credential);
httpResponse = requestFactory.buildGetRequest(new GenericUrl("https://apis.naver.com/nidlogin/nid/getUserProfile.xml")).execute();
InputStream is = httpResponse.getContent();