Skip to content

pitriq/stackexchange_auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published