We have an Authservice which following the OAuth2 protocoll. The url is the following:
https://auth.domaon.com/web/login?client_id=client&login_redirect_uri=%2Fweb%2Fauthorize&redirect_uri=????????&response_type=code&state=somestate
How can I use it to login my users in our mobile app?
I tryed to Linking it.
openAuth() {
Linking.openURL('URL above');
}
componentDidMount() {
Linking.addEventListener('url', this._handleURL);
}
_handleURL(event) {
console.log(event.url);
console.log(event.url.split('#')[1].split('=')[1].split('&')[0]);
}
I don't know what I have to add to my redirect URL to redirect to my app.
I resolved it:
<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="schema"
android:host="url" />
</intent-filter>
Have to add it to Manifest.xml
App accessible on the schema://url path.
Related
I need your help. I'm trying to get a token from the spotify api.
String url = "https://accounts.spotify.com/authorize?client_id=MyClientId&response_type=code&redirect_uri=http://127.0.0.1:8888/callback&scope=user-read-playback-state user-read-private user-read-currently-playing streaming user-read-playback-position";
final result = await FlutterWebAuth.authenticate(
url:
url,
callbackUrlScheme: "com.dada.spotiblind",
);
The request work properly except the redirect_uri.
"the webpage at ... could not be loaded because : net::ERR_CONECTION_REFUSED"
i have tried to enable deep link on the manifest :
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="http://127.0.0.1:8888/callback" />
<data android:scheme="https" />
</intent-filter>
But the app doesn't build cause to the
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />.
Also i don't understand if i have to replace my intent-filter or just add this one.
Some people says to just put the app name : Flutter: Oauth2 - Problems with redirect uri
But i have to set a white list on the spotify api parameters and i need a valid uri and not just an app name.
I'm sure i don't understand something here and thats why i need some help.
Thanks
I have an issue with a flutter implementation on Android. On iOS it works fine.
Here is my AndroidManifest.xml:
<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="com.mycomp.myapp"/>
</intent-filter>
I defined the SpotifyClient like that:
class SpotifyOAuth2Client extends OAuth2Client {
SpotifyOAuth2Client({required String redirectUri, required String customUriScheme}) :
super(
authorizeUrl: 'https://accounts.spotify.com/authorize',
tokenUrl: 'https://accounts.spotify.com/api/token',
redirectUri: redirectUri,
customUriScheme: customUriScheme) {
this.accessTokenRequestHeaders = {'Accept': 'application/json'};
}
}
And here is where I try to call the client:
OAuth2Client client = SpotifyOAuth2Client(
redirectUri: 'com.mycomp.myapp://callback',
customUriScheme: 'com.mycomp.myapp');
var authResp = await client.requestAuthorization(
clientId: 'huhuhuhuhuhuhuhuhu',
customParams: {'show_dialog': 'true'},
scopes: ['user-read-private', 'user-read-playback-state', 'user-modify-playback-state', 'user-read-currently-playing', 'user-read-email']);
print(authResp.code);
The app is correctly triggering the authorization to Spotify. I get to log in and accept on the web browser.
Then I get redirected to myApp but nothing happens. The print(authResp.code) (and of course everything following) above never fires.
Again, on iOS I have no issue.
I have been trying many thing but with no success. Any help would be much appreciated!
After many trials, I have been able to fix the issue.
Hope it can help somebody else.
Adding the following activity (and not only intent-filter in an existing activity) made the trick:
<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="com.mycomp.myapp" android:host="callback" />
</intent-filter>
</activity>
hi can you share the code? my code no works when try to add another activity
<activity
android:name="io.flutter.embedding.android.SplashScreenDrawable">
<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="com.mycomp.myapp" android:host="callback" />
</intent-filter>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
</activity>
I want it to be possible to share web pages with my react native app. After the user will share with my app, I need to be able to extract the url.
This is part of my AndroidManifest.xml
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<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" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"/>
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
<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="http"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
And this is my code in react native where I am trying to retrieve the url -
useEffect(() => {
Linking.getInitialURL().then((url) => {
if (url) {
alert('got url ', url);
}
}).catch((e) => {
alert('got some error ', e)
});
}, []);
useEffect(() => {
const callback = (url) => alert("get url when app was open " + decodeURI(url));
Linking.addEventListener('url', callback);
return () => {
Linking.removeEventListener('url', callback);
};
}, []);
There are 2 options here - one when the app is already open and the other when the app was opened by the share process.
I don't get the url in any of the options.
I am running the app on a real android devices attached to my laptop in non debug mode.
And it seems like the app keep refreshing itself all the time.
Can someone explain what am I doing wrong?
Thanks
I think you're mixing up deep linking and share menu.
If you want to share urls to your app, you can use this extension https://www.npmjs.com/package/react-native-share-menu. This will add your app as a target while sharing from other apps/browser.
const handleShare = useCallback((item: ?SharedItem) => {
if (!item) {
return;
}
const { mimeType, data, extraData } = item;
setSharedData(data);
setSharedMimeType(mimeType);
// You can receive extra data from your custom Share View
console.log(extraData);
}, []);
useEffect(() => {
ShareMenu.getInitialShare(handleShare);},
[]);
You can find the url youre looking for in "data" field of "item: ?SharedItem"
I want to open my component in Application Android (Nativescript) from a link in email, that is Click here to reset password
I have a link like this in email:
http://secsystem.domain.tk/v1/resetPassword/11E8FC9
So when I click the link from my mobile browser I need the app Launched in component resetPassword.
I use the following code:
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:scheme="http" android:host="secsystem.domain.tk" android:path="/v1/resetPassword"></data>
</intent-filter>
This code works good only in this url: http://secsystem.domain.tk/v1/resetPassword
I want to work in this url: http://secsystem.domain.tk/v1/resetPassword/11E8FC9
In routing.ts I write this code:
{ path: 'v1/resetPassword/:id', component: ResetPassIdComponent },
I want to open this component when I click in link.
Is there any solution for this?
You should use android:pathPattern when the path has dynamic parameter.
Example
<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="http" android:host="secsystem.domain.tk" android:path="/v1/resetPassword/.*"></data>
</intent-filter>
So far this is all about making Android understand it has to open this app when this particular URL pattern is matched. Angular has nothing to do here. If you want to navigate to particular component when app is opened with this URL pattern, then you must handle it manually.
Install nativescript-urlhandler plugin and query the URL that was used to open the app in the app component and initiate navigation in your router accordingly.
import { Component, OnInit } from "#angular/core";
import { handleOpenURL, AppURL } from 'nativescript-urlhandler';
#Component({
selector: "gr-main",
template: "<page-router-outlet></page-router-outlet>"
})
export class AppComponent {
constructor() {
}
ngOnInit(){
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
});
}
}
This is what I got in my Manifest:
<activity
android:name=".activities.VidyoSampleActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize">
<intent-filter>
<data android:scheme="facetalk" android:host="open"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_hjyeOhAByhF1x452yXtuEjdpCzhMiEAB" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="c13e89c059c32c08041932f2d48b4e5bf1054b4a" />
I am using this version: compile 'io.branch.sdk.android:library:2.+'
And I do in my Application class the initialization.
This is the url scheme I have set on my dashboard.branch.io: facetalk://
But when I try this link:
facetalk://facetalk.vidyo-nl.com/mobile.html?key=saETMuvxjeW2akgzbyt46Xffio&guestname=Test123&secure=yes
It does nothing.
Why is that?
I even created the code for branch from the Fabric AndroidStudio plugin. and it still doesn't work. What am I doing wrong?
Let me know if more info is needed
PS: If I remove from the intent filter this:
android:host="open"
It will work. But I don't think it goes via branch like that. cause it doesn't enter this:
Branch branch = Branch.getInstance();
branch.initSession(new Branch.BranchReferralInitListener() {
#Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
Log.i("BranchConfigTest", "deep link data: " + referringParams.toString());
}
}
}, this.getIntent().getData(), this);
After adding some logs. I found out that this is getting logged, when the app starts the first time:
11-16 12:18:45.237: I/BranchConfigTest(25065): deep link data: {"+is_first_session":false,"+clicked_branch_link":true,"room":"DpoxihjuKKKE24FAP2ByTILdZsg","guestname":"John","secure":"true","$marketing_title":"Join Conference","$one_time_use":false,"~creation_source":1,"~feature":"marketing","~id":"325753563785928408","~marketing":true,"+click_timestamp":1479295095,"+match_guaranteed":true,"~referring_link":"https:\/\/facetalk.app.link\/join?room=DpoxihjuKKKE24FAP2ByTILdZsg&guestname=John&secure=true"}
I don't understand how this is being shown? Cause I just launch the app, I did not press any link.
Also when I press on a link I created, this does not get called anymore
Alex from Branch.io here: you need to create a Branch link and test with that URL. Directly entering the deep link path with the URI scheme is not the correct implementation and (as you discovered) will not work.
The Branch.io Integration shows that I need to add the intent as this:
<intent-filter>
<data android:scheme="facetalk" android:host="open"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
But that did not work for me for branch 2.x.
This was the way I was able to add the intent:
<intent-filter android:autoVerify="true">
<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" android:host="facetalk.app.link" />
</intent-filter>