CALLBACK_URL not return to my app because: err:unknown_url_schema


#1

Here I show you my code, is authorized but fails “err:unknown_url_schema” . If instead put another https://myapp.com url redirects me to twitter. onNewIntent never enters.

private static final String CONSUMER_KEY = “xxxxxxx”;
private static final String CONSUMER_SECRET = “xxxxx”;

private static final String REQUEST_URL = "https://api.twitter.com/oauth/request_token";
private static final String AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize";
private static final String ACCESS_URL = "https://api.twitter.com/oauth/access_token";
private static final String CALLBACK_URL = "SCHEME://HOST";
private CommonsHttpOAuthConsumer httpOauthConsumer;
private OAuthProvider httpOauthprovider;
private String authUrl = "";

@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.alar);
	codigoRespuesta = (TextView) findViewById(R.id.codigoRespuesta);
	botonAutorizar = (Button) findViewById(R.id.botonAutorizar);
	campoTweet = (TextView) findViewById(R.id.tweet);
	botonEnviarTweet = (Button) findViewById(R.id.botonEnviarTweet);
	botonAutorizar.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			autoriza();
		}
	});
	botonEnviarTweet.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			// aun no hace nada
		}

	});
}

private void autoriza() {
	try {

		httpOauthConsumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY,	CONSUMER_SECRET);
		httpOauthprovider = new DefaultOAuthProvider(REQUEST_URL,	ACCESS_URL, AUTHORIZE_URL);
		new Thread(new Runnable() {
			public void run() {

				try {
					authUrl = httpOauthprovider.retrieveRequestToken(
							httpOauthConsumer, CALLBACK_URL);


				} catch (OAuthMessageSignerException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (OAuthNotAuthorizedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (OAuthExpectationFailedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (OAuthCommunicationException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}).start();
		if(!authUrl.equals(""))
		this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));

	} catch (Exception e) {
		Log.e("GH", "Fallo la autorizacion");
		codigoRespuesta.setText(e.getMessage());
	}

#2

Is solved by renaming the schema for an invented and I named host package and it works.


#3

@ descubrealar Dalar
Itt megmutatom neked a kódot, engedélyezett, de nem “err: unknown_url_schema”. Ha ehelyett egy újabb https://myapp.comurl átirányítások, hogy twitter. onNewIntent nem lép.

privát statikus végső string CONSUMER_KEY = "xxxxxxx"
privát statikus végső string CONSUMER_SECRET = “xxxxx”;

privát statikus végső string REQUEST_URL = "https://api.twitter.com/oauth/request_token"
privát statikus végső string AUTHORIZE_URL = "https://api.twitter.com/oauth/authorize"
privát statikus végső string ACCESS_URL = "https://api.twitter.com/oauth/access_token"
privát statikus végső string CALLBACK_URL = "RENDSZER :confused: / HOST"
magán CommonsHttpOAuthConsumer httpOauthConsumer,
magán OAuthProvider httpOauthprovider;
Privát String authUrl = “”;

@ Override
public void OnCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState)
setContentView (R.layout.alar)
codigoRespuesta = (TextView) findViewById (R.id.codigoRespuesta)
botonAutorizar = (gomb) findViewById (R.id . botonAutorizar)
campoTweet = (TextView) findViewById (R.id.tweet)
botonEnviarTweet = (gomb) findViewById (R.id.botonEnviarTweet)
botonAutorizar.setOnClickListener (új View.OnClickListener () {
@ Override
public void onClick (megtekintés v) {
autoriza ();
}
});
botonEnviarTweet.setOnClickListener (új View.OnClickListener () {
@ Override
public void onClick (megtekintés v) {
/ / nincs aun hace nada
}

});
}

private void autoriza () {
try {

httpOauthConsumer = new CommonsHttpOAuthConsumer (CONSUMER_KEY, CONSUMER_SECRET)
httpOauthprovider = new DefaultOAuthProvider (REQUEST_URL, ACCESS_URL, AUTHORIZE_URL)
Új téma (új futtatható () {
public void run () {


#4

@ Override
public void OnCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState)
setContentView (R.layout.alar)
codigoRespuesta = (TextView) findViewById (R.id.codigoRespuesta)
botonAutorizar = (gomb) findViewById (R.id . botonAutorizar)
campoTweet = (TextView) findViewById (R.id.tweet)
botonEnviarTweet = (gomb) findViewById (R.id.botonEnviarTweet)
botonAutorizar.setOnClickListener (új View.OnClickListener () {
@ Override
public void onClick (megtekintés v) {
autoriza ();
}
});
botonEnviarTweet.setOnClickListener (új View.OnClickListener () {
@ Override
public void onClick (megtekintés v) {
/ / nincs aun hace nada
}

});
}

private void autoriza () {
try {

httpOauthConsumer = new CommonsHttpOAuthConsumer (CONSUMER_KEY, CONSUMER_SECRET)
httpOauthprovider = new DefaultOAuthProvider (REQUEST_URL, ACCESS_URL, AUTHORIZE_URL)
Új téma (új futtatható () {
public void run () {

try {
authUrl = httpOauthprovider.retrieveRequestToken (
httpOauthConsumer, CALLBACK_URL);

} Catch (OAuthMessageSignerException e) {
/ / TODO Auto generált catch blokk
e.printStackTrace ();
} catch (OAuthNotAuthorizedException e) {
/ / TODO Auto generált catch blokk
e.printStackTrace ();
} catch (OAuthExpectationFailedException e) {
/ / TODO Auto generált catch blokk
e.printStackTrace ();
} catch (OAuthCommunicationException e) {
/ / TODO Auto generált catch blokk
e.printStackTrace ();
}
}
}). start ()
if (! authUrl.equals ( “”))
this.startActivity (új szándék (Intent.ACTION_VIEW, Uri.parse (authUrl)));

} Catch (Exception e) {
Log.e (“GH”, “Fallo la Autorización”);
codigoRespuesta.setText (e.getMessage ());
}