url_auth_web 0.0.2 copy "url_auth_web: ^0.0.2" to clipboard
url_auth_web: ^0.0.2 copied to clipboard

Platformweb

Flutter OAUTH2 plugin for web

URL AUTH WEB #

This is a flutter plugin that simplifies the auth process for OAUTH2 implementations on flutter web

Step one #

First step in using this plugin is to call the plugin to open the authentication URL

  await UrlAuthWeb().launch(url)
  // features can be passed as a string to configure the window behaviour

  // name can alse be passed to handle browser behavours

Find all parameters here


Step two (optional) #


You need to create a file in web/auth.html having your server redirect to this page. set the content of this file to

<!DOCTYPE html>
<title>Authentication complete</title>
<p>
  Authentication is complete. If this does not happen automatically, please
  close the window.
  <script>
    const url = new URL(window.location.href);
    const code = url.searchParams.get("jwt");
    const redirectUrl = new URL(`${url.origin}`);
    const page = "#/auth";
    window.location = `${redirectUrl.href}${page}?jwt=${code}`;
    // set the text of page equal to a path to a page in your app
  </script>
</p>

N/B: You can ignore this step and configure the redirect from your server

Step 3 #


In your auth page fetch the query parameters and handle it as you please

await UrlAuthWeb().getQueryParams();
/*This method returns the queryParameters as a Map<String, dynamic> e.g
{
    'jwt': {{jwt}}
}
*/
0
likes
120
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter OAUTH2 plugin for web

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on url_auth_web