Skip to content

Demonstrates login to stackoverflow on Android, not tested, not my code. Recommended to add try catch or something to prevent app crashes. Error handling is poor.

License

Notifications You must be signed in to change notification settings

knowingbros/stackoverflow-stackexchange-login-android

Repository files navigation

Stackoverflow login - Android App

Documentation: https://api.stackexchange.com/docs/authentication

Table of Contents

1 Create an app on stackapps

url

https://stackapps.com/apps/oauth/register

example

2 On successful app creation, you will get details

example

3 In SessionUtil file, add relevant details

SessionUtil.kt

example

4 Create secrets.properties in the root folder and add "key"

STACK_EXCHANGE_KEY="YOUR_KEY_HERE"

Remember to add "key" and not secret.

example

5 In AndroidManifest.xml, add host and scheme

Notice the resemblance in host and scheme here and the redirect_uri in step 3. They should match.

example

6 Run the app and click on login button

Click on the login button in our app. On clicking login button, a browser will open and there you would need to login to stackoverflow.

example

7 Login to stackoverflow and then approve the app

example

8 You will be redirected to app upon clicking "approve" on step 7

Notice, the login button is hidden and logout button is shown now.

example

9 Now on clicking update button in app, you will see the response from server in the Android Studio logcat.

Open Android Studio logcat and notice the response on clicking "update" button.

The update button will send request to this endpoint in StackExchangeApiService.kt

@GET("/me?order=desc&sort=reputation&site=stackoverflow")
suspend fun getMyReputation(): String

The Documentation for above endpoint is here: https://api.stackexchange.com/docs/me

You can modify endpoints and do whatever at this point.

example

10 Documentation

Find more Documentation, API endpoints here: https://api.stackexchange.com/docs/

example

About

Demonstrates login to stackoverflow on Android, not tested, not my code. Recommended to add try catch or something to prevent app crashes. Error handling is poor.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages