How to receive twitter oauth token? - android

Request OAuth (when twitter button cliked)
final String TW_CALLBACK_URL_STRING = "http://test.com/callback";
final Uri TW_CALLBACK_URI = Uri.parse(TW_CALLBACK_URL_STRING);
twitter4j.auth.RequestToken twRequestToken =
twitter.getOAuthRequestToken(TW_CALLBACK_URI.toString());
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(twRequestToken.getAuthorizationURL()));
activity.startActivityForResult(intent, TWITTER_REQUEST_CODE);
Manifest
<activity android:name=".TwitterLinkActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="http"
android:host="test.com" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Twitter Developer App Settings
Clicking twitter button on my app, Web Browser (chrome android) is opened.
And I log in twitter account and click "accept app" button ("애플리케이션 승인" in below image, UZTest is my test twitter app name.)
I am not native English speaker. So I do not know exactly words in English...
I think browser link to http://test.com/callback?~~~~. And My app catch this url, and start activity.
But my app can not... It just link http://www.test.com in chrome android browser.
I tried change callback url = "myapp://test.com", but only http(or https) is only available. (Twitter Developer)
How can I receive oauth token?

I did sovle it!
Below two value is not same value (?)
final String TW_CALLBACK_URL_STRING = "http://test.com/callback";
Callback URL: http://test.com/callback (OAuth Setting in Twitter Developer)
1 is only use my app. So I change to "myscheme://myhost" in java code and manifest file.
2 is not oauth request callback url (I do not know exactly what.)
Then It works fine.

Related

android open the browser with ACTION_VIEW then get callback data and return to app?

I have an e-payment address that I call with the following command from an android app
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(MyPaymentAddress));
startActivity(browserIntent);
If the payment is made correctly, the browser will be taken to a new page that displays this information in one line:
OK1,Tracking Code:443,Your payment is complete:XXXXX-XXXX-XXXXXXXX
And if I click the Cancel button on the payment page, the browser will show a new page with the following information:
CANCELL,0
Now I do not know how to not show these pages and read this information in Activity after successful payment or cancellation and return to first activity.
In your Manifest :
<activity android:name=".HomeActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="anyname" />
</intent-filter>
</activity>
Then in Server side callback URL should be "anyname://HomeActivity"
For example:
<a href="anyname://HomeActivity" > go to my application </a>
I Solved My Problem With google DeepLink Technology

Flutter Spotify Api Authentication

I need to authenticate user in my Flutter app which uses Spotify api.
I use flutter_web_auth to open WebView and let user login there.
I can't make it to return to app.
In Spotify Dashboard i have callback Uri set to: https://spotifydata.com/callback
final callbackUrl = "https://spotifydata.com/callback";
void _authenticateSpotfy() async {
final url = Uri.https('accounts.spotify.com', '/authorize', {
'response_type': 'code',
'client_id': clientID,
'redirect_uri': 'https://spotifydata.com/callback:/',
'scope': 'user-read-private user-read-email',
});
final result = await FlutterWebAuth.authenticate(
url: url.toString(), callbackUrlScheme: callbackUrl);
}
AndroidManifest.xml
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https://spotifydata.com/callback" />
</intent-filter>
</activity>
I have tried other answers on Stack but they don't seem to work.
As mentioned in Spotify's API docs, authentication redirects the user to the defined redirect_uri on successful request. Trying to log-in on https://spotifydata.com/, it has redirect_uri set as redirect_uri=https%3A%2F%2Fspotifydata.com%2Fsongdata. Make sure that the defined redirect_uri matches the callback scheme configured in the Manifest file since this enables the app to handle the redirect URL via the intent-filter.

How to avoid deep linking loop?

In my android app, I implemented a deep link so that when the user accessed my website, it offers to open it via my mobile app.
<activity
android:name=".MyActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<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="myhost"
android:pathPrefix="/myprefix"
android:scheme="http" />
<data
android:host="myhost"
android:pathPrefix="/myprefix"
android:scheme="https" />
</intent-filter>
</activity>
Some of the features in my website is not implemented in the mobile. That's why I'm opening the browser for the user whenever they want to access that certain feature.
try {
Uri intentData = Uri.parse(url);
Intent httpIntent = new Intent(Intent.ACTION_VIEW);
httpIntent.setDataAndType(intentData, "text/plain"); //NON-NLS
startActivity(httpIntent);
} catch (Exception e) {
//print error that user has no browser
}
The problem I'm having is that, after opening the browser, chrome is asking the user whether they want to open the url via chrome or my app. I want to avoid that because I'm the one redirected them to the browser.
This thread is the only one I found related to my question, unfortunately it has no answer.

Google Plus deeplinking

I trying to make a deep link to my application with google plus. According this guide I implemented a deep linking for my app. But didn't worked.
For last 2 days I made a lot of attempts to change my implementation according some other examples but still doesn't works. Now my solution look like this:
AndroidManifest.xml
<activity android:name="com.silkwallpaper.ParseDeepLinkActivity">
<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:scheme="silk-paints.com" android:host="deeplink"/>
</intent-filter>
</activity>
Sharing to google
private static final String DEEP_LINK_URL = "silk-paints.com://deeplink/";
public static void shareGP(final Activity activity, final TrackEntity track) {
Intent shareIntent = new PlusShare.Builder(activity).addStream(Uri.parse(track.urlShare))
.setText(DEEP_LINK_URL)
.setType("text/plain")
.setContentUrl(Uri.parse(track.urlShare))
.setContentDeepLinkId(DEEP_LINK_URL)
.getIntent();
activity.startActivityForResult(shareIntent, GP_REQUEST_CODE);
}
But all I get is a post in my Google+ page. Clicking on this post not redirecting me to application. What I do wrong?
According to documentation: If you have a web presence that you can link to, you should use that URL for both the content URL and the deep-link identifier so that Google can retrieve the snippet data for you to use in the shared post.
So you can try this:
AndroidManifest.xml:
<intent-filter>
<action android:name="com.google.android.apps.plus.VIEW_DEEP_LINK" />
<data android:scheme="vnd.google.deeplink" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Sharing with deep linking:
Intent shareIntent = new PlusShare.Builder(this)
.setText("Check out: http://silk-paints.com/")
.setType("text/plain")
.setContentUrl(Uri.parse("http://silk-paints.com/"))
.setContentDeepLinkId("http://silk-paints.com/")
.getIntent();
startActivityForResult(shareIntent, 0);
Check out also Handling incoming deep links.

Where I can modify twitter oauth sheme and host?

Before about 2 month, I create android app and add twitter app in twitter developers.
And I did oauth with twitter.
strings.xml
<string name="twitter_sign_in_scheme">myappname</string>
<string name="twitter_sign_in_host">twitter</string>
AndroidMenifest
<activity android:name=".TwitterLinkActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:scheme="#string/twitter_sign_in_scheme"
android:host="#string/twitter_sign_in_host" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
It did and does work fine.
Now I need to modify scheme and host. But I can not find where to modify.
In my memory, callback url contains oauth scheme and host.
But my twitter app setting does not contain. (See below image) But Oauth works.
My eyes are crazy...? I can not find where...
Please let me know where to modify twitter oauth scheme and host.
Oh my god....
Twitter Oauth url settings are not in online...
I set in code when get request token...
TwitterFactory.getSingleton().getOAuthRequestToken(
context.getString(R.string.twitter_sign_in_scheme)+"://"
+context.getString(R.string.twitter_sign_in_host) );

Categories

Resources