15

I am building an Android application that requires OAuth. I have all the OAuth functionality working except for handling the callback from Yahoo. I have the following in my AndroidManifest.xml :

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

Where www.test.com will be substituted with a domain that I own. It seems :

  • This filter is triggered when I click on a link on a page.
  • It is not triggered on the redirect by Yahoo, the browser opens the website at www.test.com
  • It is not triggered when I enter the domain name directly in the browser.

So can anybody help me with

  • When exactly this intent-filter will be triggered?
  • Any changes to the intent-filter or permissions that will widen the filter to apply to redirect requests?
  • Any other approaches I could use?

Thanks for your help.

2
  • Can you please elaborate some code on how to use oauth in android with yahoo? Commented May 9, 2011 at 13:55
  • I have the same problem, but with LinkedIn, and since I can't use a redirect URL that is not HTTP/HTTPS, I'm forced to use a WebView. Did you managed to fix this issue, without resorting to a custom scheme? Commented Jan 22, 2020 at 14:59

3 Answers 3

14

So I changed my approach to use a custom scheme, rather than a web URL and it now all works as expected.

So my callback URL is:
X://callback

and my intent-filter is:

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

where X is the name of my customer scheme.

Sign up to request clarification or add additional context in comments.

1 Comment

If you are working with authorizers that only accept redirect Url's with the HTTP/HTTPS schemes, you are locked on this issue.
0

For OAUTH please make sure you are using V2 because V1 will be deprecated soon.

 <intent-filter android:label="filter_react_native">
           <action android:name="android.intent.action.VIEW" />
           <category android:name="android.intent.category.DEFAULT"/>
           <category android:name="android.intent.category.BROWSABLE" />
           <data android:host="www.test.com" android:scheme="https"/>
     </intent-filter>

URI generated will be https://www.test.com

for

below example of an app data intent

 <data android:host="people" android:scheme="peopleapp"/>

uri generated will be peopleapp://people

Please check if you are using router, If yes then you should have people screen in you stack navigator.

At last,

For the best way to test your intent data uri is:

  1. Uninstall the existing app if not done yet.

  2. Sync and build the code again.

  3. Call a webview in your app with the uri peopleapp://people.

  4. It should work.

  5. if you are using simulator check the below link provided by android here

  6. Run this in your terminal(try adb devices to test).

    $ adb shell am start
         -W -a android.intent.action.VIEW
         -d <URI> <PACKAGE>
    
  7. URI will be peopleapp://people

  8. PACKAGE will be your package/application/ name ie..@string/app_name.

Hope this helps you.

Comments

0

It is not triggered when I enter the domain name directly in the browser.

That's by design.

When you type a URL in the browser on Android, it doesn't trigger any intent that can be opened in any app, because you just want to visit the URL you entered.

Now, if you click a URL somewhere, then Android tries to find an app that supports that URL and opens it.

Source: https://developer.android.com/training/app-links#android-app-links

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.