This article lists OAuth error codes, their causes, and actions you can take to resolve them. Your app should catch all these errors and handle them appropriately.
Canva handles the OAuth flow and token retrieval, so you might need to contact Canva support(opens in a new tab or window) for certain errors.
Error types
The requestAuthorization
and getAccessToken
methods can throw two types of errors:
CanvaError
OauthError
. A subclass ofCanvaError
, this contains anoauthCode
property and acode
property. The possible values are listed in the following tables.
To handle errors, we recommend displaying a message to let the user know that something has gone wrong, and offer them an opportunity to retry. You can then extend this approach, for example, if the user denies the request, then offer reassurance that the app requires them to login and grant permissions. Your app can also retry transient errors, such as server errors.
Error codes
oauthCode | code | Details |
---|---|---|
invalid_request | bad_request |
|
access_denied | permission_denied |
|
unauthorized_client | not_allowed |
|
invalid_client | bad_request |
|
invalid_scope | bad_request |
|
server_error | bad_external_service_response |
|
temporarily_unavailable | bad_external_service_response |
|
invalid_grant | bad_request |
|
Error codes for Identity Providers
The following errors can occur because of the way an Identity Provider has implemented OAuth. As a result, you might not be able to resolve them yourself, and might have to contact your Identity Provider's support team.
oauthCode | code | Details |
---|---|---|
unsupported_response_type | bad_request |
|
unsupported_grant_type | bad_request |
|
unsupported_token_type | bad_request |
|
Testing OAuth
When testing your app's OAuth integration, we recommended building a test plan that includes these practices:
- Scenario exploration: Document how you think these errors might manifest themselves in your app.
- Test data: Link your test data used for these scenarios.
- Management approach: Describe how you will manage these errors and provide sample screenshots.
Test environments and users
It's good practice to test using a comprehensive list of users and roles that are reflective of your user base. This helps ensure that your users have a good authorization experience, and see the right data.
For example, these questions can help you get started:
-
Planning for account types and user roles:
- What account types and user roles will your end users use with this app?
- What scopes do the users have access to?
-
Test environment: User account data
- List links to the test environment, user account, and test data that was used during testing. This should be representative of the types of users that will use the app. For example:
- User Account:
Joe Bloggs
- Environment (link):
[Link to Environment]
- Notes:
[Additional Notes]
- User Account:
- List links to the test environment, user account, and test data that was used during testing. This should be representative of the types of users that will use the app. For example:
Basic test flow
To help you get started, this is an example of a basic OAuth test flow. This isn't a complete list of everything you should test.
- Users can successfully log in and log out.
- If users grant access using the consent prompt, they are then given access to the data.
- If users deny access to the consent prompt, they aren't logged in.
- Token refresh and expiry are working as expected.
- If the user removes the app and then uses it again, they are prompted for reauthorization.
- OAuth works on the Canva desktop application and mobile website.