I'm developing an application with Instagram integration. For this I use the GitHub project jInstagram (https://github.com/sachin-handiekar/jInstagram).
If you want to log in to Instagram you have to set a redirect url. My first question is: What is this URL for? I didn't find detailed information about this. The code in jInstagram looks like this:
InstagramService service = new InstagramAuthService()
.apiKey("your_client_id")
.apiSecret("your_client_secret")
.callback("your_callback_url")
.build();
Source: https://github.com/sachin-handiekar/jInstagram/wiki/jInstagram-Usage
To get the access token I have to create a verifier and generate an access token from this. In jInstagram's Usage the only information about this verifier is this:
Verifier verifier = new Verifier("verifier you get from the user");
Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
Source: https://github.com/sachin-handiekar/jInstagram/wiki/jInstagram-Usage
What do I have to pass to the verifier's constructor? I searched for an answer and discovered that I have to pass a request parameter named "code" in the code example: https://github.com/sachinhandiekar/jInstagramexamples/blob/master/src/main/java/com/sachinhandiekar/examples/InstagramTokenHandler.java
private static final String CODE = "code";
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, IOException {
String code = request.getParameter(CODE);
InstagramService service = (InstagramService) request.getServletContext().getAttribute(Constants.INSTAGRAM_SERVICE);
Verifier verifier = new Verifier(code);
Token accessToken = service.getAccessToken(verifier);
Instagram instagram = new Instagram(accessToken);
HttpSession session = request.getSession();
session.setAttribute(Constants.INSTAGRAM_OBJECT, instagram);
System.out.println(request.getContextPath());
// Redirect to User Profile page.
response.sendRedirect(request.getContextPath() + "/profile.jsp");
}
What is this code? How do I get in possession of it?
Thank you for reading this question. I'm looking forward to get answers.
Aucun commentaire:
Enregistrer un commentaire