Mallikarjun Reddy
Mallikarjun Reddy

Reputation: 39

flutter_web_auth navigation issue. after authentication from the web page the redirection is not happening back to the app with required access token

In flutter i am working with fitbit web api integration, in this process i need to authenticate the user from their web site after that i will get access_token in redirection url. So, i need to access that token and close that web page and redirect back to my application with the access token for further api call.

To achieve the above flow am using flutter_web_auth plugin

Here is my code: after clicking on a button am invokin the below method.

  void authenticate() async {
// Present the dialog to the user
print('Before Authentication');
final result = await FlutterWebAuth.authenticate(
  url: "https://www.fitbit.com/oauth2/authorize?response_type=token&client_id=22BZMN&expires_in=2592000&scope=activity%20nutrition%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight&redirect_uri=https://tekfriday.com", //TODO: add &prompt=login to shwo login screen every time.
  callbackUrlScheme: "tekfriday",
);
final token = Uri.parse(result).queryParameters['token'];
print('token');
print(token);

}

Here is my manifest file:

        <activity android:name="com.tekfriday.wear_poc.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="tekfriday" />
        </intent-filter>
    </activity>

The authentication flow is happening properly, But after authentication it is not redirecting back to my application. Is there any mistake in above code ?.

Upvotes: 4

Views: 1833

Answers (1)

Mochte
Mochte

Reputation: 1

Chance manifest
<data android:scheme="tekfriday"/> => <data android:scheme="com.tekfriday" android:host="login"/>
and
...?redirect_uri=https://tekfriday.com" => ...?redirect_uri=com.tekfriday://login"

Upvotes: 0

Related Questions