Guides

OAuth (Open Authorization) is a protocol that allows a client to access a user’s resources on a server without requiring the user’s login credentials. With OAuth, users can log into third-party apps using their Deriv accounts without sharing passwords or API tokens, providing a secure and convenient option.

OAuth2 is a secure method for developers to grant app access to users, although it requires a few more setup steps. It is the best way to ensure security while enabling third-party access.

How to use OAuth authorization

To set up OAuth authorization for your app, follow these steps:

  1. Specify the OAuth redirect URL: Go to the app registration page and enter the URL you want to use as the OAuth Redirect URL in the "Website URL" field.

  2. Add a login button:

    1. Add a login button to your website or app that directs users to:

      https://oauth.deriv.com/oauth2/authorize?app_id=your_app_id

    2. Replace your_app_id with your actual app ID.
  3. Handle user redirection: After a user logs in, they will be redirected to the URL you specified as the Redirect URL. This URL will include parameters with the user's session tokens, which will look something like this:

    https://[YOUR_WEBSITE_URL]/redirect/?acct1=cr799393&token1=a1-f7pnteezo4jzhpxclctizt27hyeot&cur1=usd&acct2=vrtc1859315&token2=a1clwe3vfuuus5kraceykdsoqm4snfq&cur2=usd&state=

  4. Extract tokens from the URL: In the URL parameters, you'll see all the accounts and their corresponding session tokens. Use these tokens in the Authorize API call to perform actions on behalf of the user.

By following these steps, you can securely integrate OAuth into your app, providing a seamless and safe login experience for your users.