Connect OAuth reference
This reference lists available public methods for our OAuth endpoints for Connect.
The OAuth Connect flow allows you to customize the user’s experience by passing additional parameters to Stripe. Some common examples are explained below, and the rest of the reference lists every possible option.
Note
As a platform, remember that data you create for a Standard account (that is, charges, customers, invoices, and so on) will be visible on their Stripe account. This also means if they connect other platforms, those platforms will have access to that data too.
Starting in June 2021, Platforms using OAuth with read_
scope won’t be able to connect to accounts that are controlled by another platform.
Extensions won’t experience any changes to how OAuth behaves. Learn more about OAuth changes for Standard Platforms.
Common examples
Prefill fields
Provide the best possible user experience for users who need to create a new Stripe account by prefilling the account form fields with information you already have, like the user’s email and name. Prefilling has no effect if your user already has a Stripe account. You can’t prefill certain fields, including terms of service acceptance and RISA acceptance in Japan.
Dynamically set the redirect URI
For security purposes, Stripe redirects a user only to a predefined URI. However, Connect allows you to define more than one redirect URI, which you can use to further customize the user’s experience. For example, you could redirect some of your users back to https://sub1.example.com and others to https://sub2.example.com.
To dynamically set the redirect URI:
- In your platform settings, add each redirect URI.
- Add a
redirect_
parameter to your authorization request and set the value to one of your redirect URIs.uri
https://connect.stripe.com/oauth/authorize?response_type=code&client_id={{CLIENT_ID}}&scope=read_write&redirect_uri=https://sub2.example.com
If no redirect_
is specified in the URL, then Stripe uses the first URI configured in your platform settings.
Authorize the account
For Standard accounts: GET https://connect.stripe.com/oauth/authorize
Sends the user to Stripe to connect to your platform.
Request
Parameter | Description |
---|---|
client_ | The unique identifier provided to your application, found in your application settings. |
response_ | The only option at the moment is code. |
redirect_ Optional | The URL for the authorize response redirect. If provided, this must exactly match one of the comma-separated redirect_ values in your application settings. To protect yourself from certain forms of man-in-the-middle attacks, the live mode redirect_ must use a secure HTTPS connection. Defaults to the redirect_ in your application settings if not provided. |
scope OptionalStandard Only | read_write or read_only, depending on the level of access you need. Defaults to read_only for Standard accounts. Note read_only can only be specified for extensions. |
state Optional | An arbitrary string value we’ll pass back to you, useful for CSRF protection. |
The following query string parameters are all optional—we use them to prefill details in the account form for new users. Some prefilled fields (for example, URL or product category) might be automatically hidden. Any parameters with invalid values are silently ignored.
Note that some of these parameters apply only to Standard accounts (indicated).
Parameter | Description |
---|---|
stripe_ Recommended | The user’s email address. Must be a valid email format. |
stripe_ Recommended | The URL for the user’s business. This may be the user’s website, a profile page within your application, or another publicly available profile for the business, such as a LinkedIn or Facebook profile. It must be URL-encoded and include a scheme (http or https). If you prefill this field, include a description of the user’s products or services and their contact information in the linked page. If we don’t have enough information, we’ll have to reach out to the user directly before initiating payouts. |
stripe_ | Two-letter country code (for example, US or CA). Must be a country that Stripe currently supports. |
stripe_ | The business phone number. Must be 10 digits only. Must also prefill stripe_ with the corresponding country. |
stripe_ | The legal name of the business. |
stripe_ | The type of the business. For Standard accounts, the value must be sole_prop, corporation, non_profit, partnership, or llc. |
stripe_ | First name of the person filling out a Stripe application. |
stripe_ | Last name of the person filling out a Stripe application. |
stripe_ stripe_ stripe_ | Day (0-31), month (1-12), and year (YYYY, greater than 1900) for the birth date of the person filling out a Stripe application. If you choose to pass these parameters, you must pass all three. |
stripe_ Standard only | Street address of the business. |
stripe_ Standard only | Address city of the business. To prevent ambiguity, also prefill stripe_ with the corresponding country. |
stripe_ Standard only | Address state of the business. Must be the two-letter state or province code (for example, NY for a US business or AB for a Canadian one). Must also prefill stripe_ with the corresponding country. |
stripe_ Standard only | Address postal code of the business. Must be a string. To prevent ambiguity, also prefill stripe_ with the corresponding country. |
stripe_ Standard only | A string: true if the user sells a physical product, false otherwise. |
stripe_ | A description of what the business is accepting payments for. |
stripe_ Standard only | Three-letter ISO code representing currency, in lowercase (for example, usd or cad). Must be a valid country and currency combination that Stripe supports. Must prefill stripe_ with the corresponding country. |
stripe_ | The Kana variation of the first name of the person filling out a Stripe application. Must prefill stripe_ with JP, as this parameter is only relevant for Japan. |
stripe_ | The Kanji variation of the first name of the person filling out a Stripe application. Must prefill stripe_ with JP, as this parameter is only relevant for Japan. |
stripe_ | The Kana variation of the last name of the person filling out a Stripe application. Must prefill stripe_ with JP, as this parameter is only relevant for Japan. |
stripe_ | The Kanji variation of the last name of the person filling out a Stripe application. Must prefill stripe_ with JP, as this parameter is only relevant for Japan. |
stripe_ | The gender of the person filling out a Stripe application. (International regulations require either male or female.) Must prefill stripe_ with JP, as this parameter is only relevant for Japan. |
stripe_ Standard only | The Kana variation of the address block. This parameter is only relevant for Japan. You must prefill stripe_ with JP and stripe_ with a valid Japanese postal code to use this parameter. |
stripe_ Standard only | The Kanji variation of the address block. This parameter is only relevant for Japan. You must prefill stripe_ with JP and stripe_ with a valid Japanese postal code to use this parameter. |
stripe_ Standard only | The Kana variation of the address building. This parameter is only relevant for Japan. You must prefill stripe_ with JP and stripe_ with a valid Japanese postal code to use this parameter. |
stripe_ Standard only | The Kanji variation of the address building. This parameter is only relevant for Japan. You must prefill stripe_ with JP and stripe_ with a valid Japanese postal code to use this parameter. |
Response
The user’s browser is redirected back to your configured redirect URI or the value you passed in the redirect_
parameter. When successful, you receive the following query parameters:
Parameter | Description |
---|---|
code | An authorization code you can use in the next call to get an access token for your user. This can only be used once and expires in 5 minutes. |
scope | read_write or read_only, depending what you passed on the initial GET request. |
state | The value of the state parameter you provided on the initial GET request. |
Error Response
In case of an error, the user’s browser won’t be redirected except in the case of access_
. Instead, errors will be returned in a JSON dictionary with the following fields:
Parameter | Description |
---|---|
error | A unique error code per error type. |
error_ | A human readable description of the error. |
state | The value of the state parameter you provided on the initial GET request. |
Error Codes
Parameter | Description |
---|---|
access_ | User denied authorization. |
invalid_ | Invalid scope parameter provided. |
invalid_ | Provided redirect_ parameter is an invalid URL or isn’t allowed by your application settings. |
invalid_ | Missing response_ parameter. |
unsupported_ | Unsupported response_ parameter. Currently the only supported response_ is code. |
Complete the connection and get the account ID
POST https://connect.stripe.com/oauth/token
Used both for turning an authorization_
into an account connection, and for getting a new access token using a refresh_
.
Request
Make this call using your secret API key as a client_
POST parameter:
When converting an authorization code to an access token, you must use an API key that matches the mode—live or test—of the authorization code (which depends on whether the client_
used was production or development).
When using a refresh token to request an access token, you may use either a test or live API key to obtain a test or live access token respectively. Any existing access token with the same scope and mode—live or test—is revoked.
Note
Per OAuth v2, this endpoint isn’t idempotent. Consuming an authorization code more than once revokes the account connection.
Parameter | Description |
---|---|
grant_ | authorization_code when turning an authorization code into an access token, or refresh_token when using a refresh token to get a new access token. |
code or refresh_ | The value of the code or refresh_ , depending on the grant_ . |
scope Optional | When requesting a new access token from a refresh token, any scope that has an equal or lesser scope as the refresh token. Has no effect when requesting an access token from an authorization code. Defaults to the scope of the refresh token. |
Response
Parameter | Description |
---|---|
scope | The scope granted to the access token, depending on the scope of the authorization code and scope parameter. |
stripe_ | The unique ID of the account you have been granted access to, as a string. |
livemode | Indicates whether the platform’s access to perform updates on behalf of the connected account includes livemode access, or is limited to testmode actions. This matches the livemode of the application used to authorize the OAuth request. |
token_ | Always has a value of bearer. |
access_ | Deprecated Use the Stripe-Account header with your platform’s secret key (that can make requests on behalf of this Stripe account). |
stripe_ | Deprecated Use the Stripe-Account header with your platform’s publishable key (that can make requests on behalf of this Stripe account). |
refresh_ | Deprecated Can be used to get a new access token of an equal or lesser scope, or of a different live mode (where applicable). |
Error Response
Parameter | Description |
---|---|
error | A unique error code per error type. |
error_ | A human readable description of the error. |
Error Codes
Parameter | Description |
---|---|
invalid_ | No code , refresh_ , or grant_ parameter provided (where required). |
invalid_ | A variety of things can prompt this error:
|
unsupported_ | Unsupported grant_ parameter specified. The only currently supported types are authorization_code and refresh_token. |
invalid_ | Invalid scope parameter provided. |
unsupported_ | Unsupported response_ parameter. Currently the only supported response_ is code. |