Using Connect with Standard accounts

    Integrating with Standard accounts is the fastest and easiest way to get started using Connect, since you'll be offloading the majority of the user experience and user communication to Stripe.

    A Standard Stripe account is a conventional Stripe account controlled directly by the account holder (i.e., your platform’s user). A user with a Standard account has a relationship with Stripe, is able to log in to the Dashboard, can process charges on their own, and can disconnect their account from your platform.

    You can prompt your users to create Stripe accounts, or allow anyone with an existing Stripe account to connect to your platform.

    Get started

    If you’re new to Connect, start with a guide to use Standard accounts to enable other businesses to accept payments directly.

    The OAuth connection flow

    A user connects to your platform using the following OAuth connection flow:

    1. Starting on a page at your site, the user clicks a link that takes them to Stripe, passing along your platform’s client_id.
    2. On Stripe’s website, the user provides the necessary information for connecting to your platform.
    3. The user is then redirected back to your site along with an authorization code.
    4. Your site then makes a request to Stripe’s OAuth token endpoint to complete the connection and fetch the user’s account ID.

    When these steps are done, API requests can be made for the user with their account ID or authorization credentials.

    Step 1: Create the OAuth link

    To start your integration, go to your platform settings and:

    • Copy your client_id, a unique identifier for your platform that is generated by Stripe.
    • Set your redirect_uri, the URL which your user will be redirected to after connecting their account. You must specify all redirect URLs in your platform settings. If you do not include the redirect_uri parameter in your request, Stripe defaults to using the first address you have configured in your platform settings.

    Stripe also provides a development client_id to make testing easier.

    With these two pieces of information in hand, you’re ready to create the OAuth link. We recommend showing a Connect button that sends users to our authorize_url endpoint:

    https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7&scope=read_write

    The Stripe endpoint should receive at least these three parameters:

    • response_type, with a value of code
    • Your client_id
    • scope, with a value of read_write

    The scope parameter dictates what your platform can do on behalf of the connected account, with read_only being the default.

    To prevent CSRF attacks, add the state parameter, passing along a unique token as the value. We’ll include the state you gave us when we redirect the user back to your site.

    Here’s how the above URL can be presented to your user to begin the connection, along with our Connect with Stripe button:

    Connect with Stripe

    Step 2: User creates or connects their account

    After the user clicks the link on your site, they'll be taken to Stripe's website where they'll be prompted to allow or deny the connection to your platform.

    The process of creating a Stripe account is incorporated into our authorization flow. You don't need to worry about whether or not your users already have accounts.

    The user is logged in and can connect directly.

    The user needs to log in or create an account.

    Step 3: User is redirected back to your site

    After the user connects their existing or newly created account to your platform, they are redirected back to your site, to the URL established as your platform’s redirect_uri.

    For successful connections, we’ll pass along in the URL:

    • The scope granted
    • The state value, if provided
    • An authorization code. The authorization code is short-lived, and can be used only once, in the POST request described in the next step.
    https://connect.stripe.com/connect/default/oauth/test?scope=read_write&code={AUTHORIZATION_CODE}

    If the authorization was denied by the user, they'll still be redirected back to your site, but the URL includes an error instead of the authorization code:

    https://connect.stripe.com/connect/default/oauth/test?error=access_denied&error_description=The%20user%20denied%20your%20request

    Step 4: Platform completes the Standard account connection

    Include the provided authorization code in a POST request to Stripe’s token endpoint to complete the connection and fetch the user’s account ID:

    curl https://connect.stripe.com/oauth/token \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d code=ac_123456789 \ -d grant_type=authorization_code
    # Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' response = Stripe::OAuth.token({ grant_type: 'authorization_code', code: 'ac_123456789', }) # Access the connected account id in the response connected_account_id = response.stripe_user_id
    # Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' response = stripe.OAuth.token( grant_type='authorization_code', code='ac_123456789', ) # Access the connected account id in the response connected_account_id = response['stripe_user_id']
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $response = \Stripe\OAuth::token([ 'grant_type' => 'authorization_code', 'code' => 'ac_123456789', ]); // Access the connected account id in the response $connected_account_id = $response->stripe_user_id;
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Map<String, Object> params = new HashMap<>(); params.put("grant_type", "authorization_code"); params.put("code", "ac_123456789"); TokenResponse response = OAuth.token(params, null); // Access the connected account ID in the response String accountId = response.getStripeUserId();
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const response = await stripe.oauth.token({ grant_type: 'authorization_code', code: 'ac_123456789', }); var connected_account_id = response.stripe_user_id;
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.OAuthTokenParams{ GrantType: stripe.String("authorization_code"), Code: stripe.String("ac_123456789"), } token, _ := oauth.New(params) // Access the connected account id in the response connected_account_id = token.StripeUserID
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new OAuthTokenCreateOptions { GrantType = "authorization_code", Code = "ac_123456789", }; var service = new OAuthTokenService(); var response = service.Create(options); // Access the connected account id in the response connected_account_id = response.StripeUserId

    Note that you’ll make the request with your live or test secret API key, depending on whether you want to get a live or test access token back.

    Stripe returns a response that includes the account ID (stripe_user_id) for the user:

    { "token_type": "bearer", "stripe_publishable_key": "{PUBLISHABLE_KEY}", "scope": "read_write", "livemode": false, "stripe_user_id": "{ACCOUNT_ID}", "refresh_token": "{REFRESH_TOKEN}", "access_token": "{ACCESS_TOKEN}" }

    If there was a problem, we instead return an error:

    { "error": "invalid_grant", "error_description": "Authorization code does not exist: {AUTHORIZATION_CODE}" }

    You’re done! The user is now connected to your platform. Store the stripe_user_id in your database; this is the Stripe account ID for the new account. You’ll use this value to authenticate as the connected account by passing it into requests in the Stripe-Account header.

    In your application, you might want to consider using a dedicated OAuth client library to simplify these steps. To find an OAuth library for your language or framework, you can refer to the list of client libraries on the OAuth website.

    The refresh_token can be used to generate test access tokens for a production client_id or to roll your access token. You should hold on to this value, too, as you’re only able to get it after this initial POST request.

    Revoked and revoking access

    An account.application.deauthorized event occurs when a user disconnects your platform from their account. By watching for this event via webhooks, you can perform any necessary cleanup on your servers.

    To disconnect a Standard account from your platform, POST your client_id and the connected account’s ID to https://connect.stripe.com/oauth/deauthorize:

    curl https://connect.stripe.com/oauth/deauthorize \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d client_id=ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7 \ -d stripe_user_id=acct_t807e20p6vpGeg
    # Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' Stripe::OAuth.deauthorize({ client_id: 'ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7', stripe_user_id: 'acct_Zm5Y6ViYId3WEe', })
    # Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' stripe.OAuth.deauthorize( client_id='ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7', stripe_user_id='acct_2iG5vpeu0GD0nS' )
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); \Stripe\OAuth::deauthorize([ 'client_id' => 'ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7', 'stripe_user_id' => 'acct_cAYnw7WSgbuu9y', ]);
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Map<String, Object> params = new HashMap<>(); params.put("client_id", "ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7"); params.put("stripe_user_id", "acct_3U00LecmpjevEL"); OAuth.deauthorize(params, null);
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const response = await stripe.oauth.deauthorize({ client_id: 'ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7', stripe_user_id: 'acct_MhEt2VDAqaUlHx', });
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.DeauthorizeParams{ ClientID: stripe.String("ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7"), StripeUserID: stripe.String("acct_IzV8Q5OQCompNp"), } oauth.Del(params)
    // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new OAuthDeauthorizeOptions { ClientId = "ca_32D88BD1qLklliziD7gYQvctJIhWBSQ7", StripeUserId = "acct_zXFO6501Bu166O", }; var service = new OAuthTokenService(); service.Deauthorize(options);

    Next steps

    Now you can use the API on your user's behalf to accept payments, set up recurring billing, fetch account data, and more:

    Join the Stripe Partner Program to get best practices across a range of topics like how to optimize your Stripe integrations, effectively go to market, and answer frequently asked questions about Stripe and payments.

    Was this page helpful?

    Feedback about this page?

    Thank you for helping improve Stripe's documentation. If you need help or have any questions, please consider contacting support.

    On this page