[JAVA] Intent-filter does not respond with callback URL of Twitter OAuth authentication

Twitter OAuth authentication callback doesn't bring control back to my app I was addicted to it, so I made a note.


On the Twitter app registration page, Because it says that the callback URL must start with http: // or https: // At first, I tried various URLs that do not exist or exist, intent-filter did not respond.


In fact, the callback URL is

** ”Original schema: //” **

Registration is also accepted with the syntax.

Callback URL zanapp://


next, AndroidManifest.xml android: host and callback URL host Neither, I tried it with the setting, but it still does not respond.


Therefore, In the source code of the app I added ** host ** (test) to the schema of the callback URL.

(Android: host in AndroidManifest.xml and host in the callback URL There are both, and the settings. )

TwitterOAuthActivity.java


mRequestToken = mTwitter.getOAuthRequestToken(zanapp://test);

AndroidManifest.xml


<intent-filter>
	<action android:name="android.intent.action.VIEW" />
	<category android:name="android.intent.category.DEFAULT" />
	<category android:name="android.intent.category.BROWSABLE" />
	<data
		android:host="test"
		android:scheme="zanapp" />
</intent-filter>

Now with a callback from your browser's Twitter authentication ** Control returns to the app **.


Does intent-filter not respond unless it is a unique schema? ?? ?? I'm not sure why.

Recommended Posts

Intent-filter does not respond with callback URL of Twitter OAuth authentication
Oauth2 authentication with Spring Cloud Gateway
Container does not start with docker-compose