Skip to content

stytchauth/stytch-android-example

Repository files navigation

Stytch Android example application

Overview

This example application demonstrates how one may use Stytch within an Android application, using Jetpack Compose.

This project uses Stytch's Android SDK which provides headless methods to securely interact with Stytch.

This application features SMS OTP as well as Apple and Google OAuth authentication. You can use this application's source code as a learning resource, or use it as a jumping off point for your own project. We are excited to see what you build with Stytch!

Set up

Follow the steps below to get this application fully functional and running using your own Stytch credentials.

In the Stytch Dashboard

  1. Create a Stytch account. Once your account is set up a Project called "My first project" will be automatically created for you.

  2. Within your new Project, navigate to SDK configuration, and make the following changes:

    • Click Enable SDK in Test.

    • Under Authorized applications add the Bundle ID com.stytch.androidexample.

      Authorized applications
  3. Navigate to Redirect URLs, and add stytch-example://oauth as type Login and Sign-up.

    Redirect URLs
  4. Navigate to OAuth, and set up login for Apple and Google in the Test environment. Follow all the instructions provided in the Dashboard. If you are not interested in OAuth login you can skip this step. However, the Continue with Apple and Continue with Google buttons in this application will not work. NOTE: for this example app's Apple OAuth config, only Team ID and Application ID fields require real data, the other fields can be stubbed out with fake data.

    OAuth configuration
  5. Finally, navigate to API Keys, and copy your public_token. You will need this value later on.

On your machine

In your terminal clone the repo and open the Android Studio project:

git clone https://github.com/stytchauth/stytch-android-example.git

Next, add your STYTCH_PUBLIC_TOKEN and GOOGLE_OAUTH_CLIENT_ID in local.properties. In a production scenario, you might fetch this token from your backend, or configure as an env var in your CI/build pipeline.

Running the app

After completing all the set up steps above the application can be run as normally from Android Studio.

You'll be able to login with SMS OTP, Sign In With Apple, or Google OAuth and see your values from your Stytch User object as well as see how logging out works.

Next steps

This example app showcases a small portion of what you can accomplish with Stytch. Here are a few ideas to explore:

  1. Add additional login methods like Passwords or Biometrics.
  2. Take advantage of the SDK's headless methods and replace the included UI with your own look and feel.
  3. Use Stytch Sessions to secure your backend.

Get help and join the community

💬 Stytch community Slack

Join the discussion, ask questions, and suggest new features in our ​Slack community!

❓ Need support?

Check out the Stytch Forum or email us at support@stytch.com.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages