stackexchange_auth 0.0.1 copy "stackexchange_auth: ^0.0.1" to clipboard
stackexchange_auth: ^0.0.1 copied to clipboard

Authentication for Stack Exchange in Flutter, using OAuth2.0 and V2.2 API.

Stack Exchange Authentication #

Authentication for Stack Exchange in Flutter, using OAuth2.0 and V2.2 API.

This is pretty much a carbon copy of this wonderful package with a few adaptations, so props to @ishaanbahal.

So what do I do to use this? #

  • First, register on Stack Exchange here.
  • After that, head to this link to register a new application.
  • You can then get your client_id from your application's overview page.
  • If you wish to set up client side flow, enable both Client Side Flow and Desktop OAuth Redirect Uri options in your application's overview page. You can read more about that on the Desktop Aplications section here.

Cool, how do I use it? #

Here's a piece of code showing how you would implement the client side flow, taken from the example app.

MaterialButton(
    color: Colors.blue,
    onPressed: () async {
        await Navigator.push(
            context,
            MaterialPageRoute(
                builder: (context) => Scaffold(
                    appBar: AppBar(
                    leading: CloseButton(),
                ),
                body: StackExchangeLoginView(
                    clientId: 'your_client_id',
                    redirectUrl: 'https://stackoverflow.com/oauth/login_success',
                    onError: (String error) {
                        print(error);
                    },
                    onTokenCapture: (token) {
                        print('${token.token} ${token.expiry}');
                        Navigator.pop(context, token);
                    },
                    clientSideFlow: true,
                ))),
        );
    },
    child: Text('Signup/Login', style: TextStyle(color:Colors.white),),
)

For server side token collection, you would have to implement a web server capable of returning the access token.

0
likes
35
pub points
0%
popularity

Publisher

unverified uploader

Authentication for Stack Exchange in Flutter, using OAuth2.0 and V2.2 API.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, http, uuid, webview_flutter

More

Packages that depend on stackexchange_auth