Android Instagram Login -IntegrationAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Android Instagram Login -Integration

Post by Anonymous »

Ich versuche, über Instagram ohne Graph -API soziales Anmeldung durchzuführen und alle notwendigen Dinge aus der Instagram -Dokumentation und Stackoverflow zu lesen. Passwort.
[*] Client> Registrieren Sie den neuen Client und fügen Sie generierte Client -ID, geheime Taste und Umleitung von URL in meiner konstanten Datei hinzu. https://api.instagram.com/oauth/authori ... ublic_Cont When I enter the username and password in WebView rather than to navigate it on redirect URL it is continuously showing me error on WebView as: {"error_type": "OAuthException", "code": 400, "error_message": "You must include a valid client_id, response_type, and redirect_uri Parameter "}
Ich möchte Access_Token aber meinen Fehler empfangen. />
public class MainActivity extends AppCompatActivity implements AuthenticationListener {

private AuthenticationDialog authDialog;
private Context context;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
context = this;
}

@Override
public void onCodeReceived(String token) {
if (token == null)
return;
}

@OnClick(R.id.buttonLogin)
public void loginClick() {
authDialog = new AuthenticationDialog(this, this);
authDialog.setCancelable(true);
authDialog.getWindow().setLayout(((getWidth(context) / 100) * 90), LinearLayout.LayoutParams.MATCH_PARENT);
authDialog.getWindow().setGravity(Gravity.CENTER);
authDialog.show();
}

public static int getWidth(Context context) {
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager windowmanager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowmanager.getDefaultDisplay().getMetrics(displayMetrics);
return displayMetrics.widthPixels;
}
}
< /code>

AuthenticationDialog.java

public class AuthenticationDialog extends Dialog {
private String TAG = AuthenticationDialog.class.getSimpleName();
private AuthenticationListener listener;
private Context context;
private WebView webView;

private final String url = Constants.BASE_URL + "oauth/authorize/?client_id=" +
Constants.INSTAGRAM_CLIENT_ID
+ "&redirect_url="
+ Constants.REDIRECT_URL
+ "&response_type=token"
+ "&scope=basic+public_content";

public AuthenticationDialog(@NonNull Context context, AuthenticationListener listener) {
super(context);

this.context = context;
this.listener = listener;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.auth_dialog);
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.loadUrl("http://api.instagram.com/");
//webView.loadUrl("https://api.instagram.com/oauth/authori ... ic_content");
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");
if (url.contains("#access_token=") && !authComplete) {
Log.d(TAG, " inside access_token");
Uri uri = Uri.parse(url);
access_token = uri.getEncodedFragment();
//get the whole token after "=" sign
access_token = access_token.substring(access_token.lastIndexOf("=") + 1);
Log.d(TAG, "token: " + access_token);
authComplete = true;
listener.onCodeReceived(access_token);
dismiss();
} else if (url.contains("?error")) {
Log.d(TAG, "getting error fetching access token");
dismiss();
} else {
Log.d(TAG, "outside both" + url.toString());
}
}
});
}
}
< /code>

und gemäß Protokollen kommt der Code in "Letzten" "Außerhalb" der WebView zeigt den Fehler, den ich in Punkt Nr. erwähnt habe. 4. < /P>

Kann jemand bitte helfen? < /P>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post