@Path("auth") @GET public Response SignUpGitHub( @QueryParam("callback_uri") String frontEndCallBackUri, @Context HttpServletRequest request) { return Response.seeOther( oauthService.getOAuthURI(request.getRequestURL().toString(), frontEndCallBackUri)) .build(); }
@Path("auth-back") @GET public Response ReceiveGitHutAuthorize( @QueryParam("code") String code, @QueryParam("state") String state, @Context HttpServletRequest request) { try { OAuthRequest oauthRequest = oauthService.receiveOAuthResponse(code, state, request.getRequestURL().toString()); GitUser user = gitHubService.createGitUser(oauthRequest); URI nextLocation = frontendService.getSuccessFrontendURI(user, oauthRequest.getFrontEndCallBackUri()); return Response.seeOther(nextLocation).build(); } catch (NoSuchOAuthRequest e) { throw new WebApplicationException(403); } catch (GitHubConnectionException e) { throw new WebApplicationException(403); } }