I know that similar threads exist but I could not find the solution for my use case.
I am trying to authentify using OAuth2 from a mobile app made with Flutter. As a example here I am showing the Android case.
The redirect url I provide must start with http(s), otherwise identity provider refuses it. I have added the following Activity in my AndroidManifest.xml:
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity">
<intent-filter android:label="flutter_web_auth" 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="my-app" />
</intent-filter>
</activity>
I am using the lib oauth2_client to make the requests.
var myOAuth2Client = new MyOAuth2Client(redirectUri: "http://my-app", customUriScheme: "http");
AccessTokenResponse tknResp = await myOAuth2Client.getTokenWithAuthCodeFlow(
clientId: 'xxxxxxxxxxxxxx',
clientSecret: 'xxxxxxxxxxxxxx',
scopes: ['the.profile']).catchError((onError) {
print("Error $onError");
});
With this, I am well redirected to the identity provider login page in the browser. Once I login with the credentials, I am not redirected to my app. Instead, I am redirected to an invalid url in the browser. Note that if I force to open the url with my app instead of browser, it works well.
I have read about Android app links, but I understood that it requires editing on server side, which I do not have access to (the goal here is to have a standalone mobile app authentifying).
Could somebody guide me on how to get redirected to my app? (If this is not possible and would require a server on my side, what would be the flow?) Thanks! :)