Skip to content

Instantly share code, notes, and snippets.

@sachin-handiekar
Last active October 3, 2019 15:05
Show Gist options
  • Save sachin-handiekar/3971607 to your computer and use it in GitHub Desktop.
Save sachin-handiekar/3971607 to your computer and use it in GitHub Desktop.
Instagram Demo
import java.util.Scanner;
import org.jinstagram.Instagram;
import org.jinstagram.auth.InstagramAuthService;
import org.jinstagram.auth.model.Token;
import org.jinstagram.auth.model.Verifier;
import org.jinstagram.auth.oauth.InstagramService;
import org.jinstagram.entity.users.basicinfo.UserInfo;
public class Demo {
private static final Token EMPTY_TOKEN = null;
public static void main(String[] args) throws Exception {
String clientId = "44e6baf1dc5d45a082cae725ffa2f36d";
String clientSecret = "c9209756c7fa49bd9de195eda95f0b54";
String callbackUrl = "http://reveal-it.appspot.com/oauthtest";
InstagramService service = new InstagramAuthService().apiKey(clientId)
.apiSecret(clientSecret).callback(callbackUrl).build();
String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
System.out.println("** Instagram Authorization ** \n\n");
System.out.println("Copy & Paste the below Authorization URL in your browser...");
System.out.println("Authorization URL : " + authorizationUrl);
Scanner sc = new Scanner(System.in);
String verifierCode;
System.out.print("Your Verifier Code : ");
verifierCode = sc.next();
System.out.println();
Verifier verifier = new Verifier(verifierCode);
Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
Instagram instagram = new Instagram(accessToken);
UserInfo userInfo = instagram.getCurrentUserInfo();
System.out.println("***** User Info ******");
System.out.println("Username : " + userInfo.getData().getUsername());
}
}
@tolgatuna
Copy link

What is verifier???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment