Não sei por que meu botão de registro também está desativado. Talvez atualização da API do Instagram. Mas eu compreendo este guia e funciona para mim. https://developers.facebook.com/docs/instagram-basic-display-api/getting-started
Atualizada :
No meu caso, estou usando o webview no android. Portanto, abaixo está o código de exemplo: (Ignore a caixa de diálogo, você pode implementar apenas a visualização na web e seu método onpagefinished)
public class AuthenticationDialog extends Dialog {
private String TAG = AuthenticationDialog.class.getSimpleName();
private AuthenticationListener listener;
private Context context;
private WebView webView;
private final String url = "https://api.instagram.com/" + "oauth/authorize/?app_id=" +
getResources().getString(R.string.app_id)
+ "&redirect_uri="
+ getResources().getString(R.string.redirect_url)
+ "&response_type=code"
+ "&scope=user_profile,user_media";
public AuthenticationDialog(@NonNull Context context, AuthenticationListener listener) {
super(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
this.context = context;
this.listener = listener;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.auth_dialog);
this.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
initializeWebView();
}
private void initializeWebView() {
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
Log.d(TAG, "url: " + url);
webView.setWebViewClient(new WebViewClient() {
String access_token;
boolean authComplete;
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
Log.d(TAG, "onPageStarted called");
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.d(TAG, "onPageFinished called " + url);
if (url.contains("?code=") && !authComplete) {
Log.d(TAG, " inside access_token");
access_token = url;
//get the whole token after "=" sign
access_token = access_token.replace("https://www.instagram.com/?code=","");
access_token = access_token.replace("#_","");
Log.d(TAG, "token: " + access_token);
authComplete = true;
listener.onTokenReceived(access_token);
webView.loadUrl("https://instagram.com/accounts/logout/");
dismiss();
} else if (url.contains("?error")) {
Log.d(TAG, "getting error fetching access token");
dismiss();
} else {
Log.d(TAG, "outside both" + url.toString());
}
}
});
}
}