This repository was archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Added Zoom OAuth doc #409
Open
asutoshranjan
wants to merge
2
commits into
appwrite:oauth-providers
Choose a base branch
from
asutoshranjan:zoom-oauth
base: oauth-providers
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added Zoom OAuth doc #409
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,342 @@ | ||
| # Zoom provider | ||
|
|
||
| Appwrite allows you to authenticate users using their Zoom account through Zoom OAuth2 provider. OAuth authentication is a great way to reduce friction for your users and increase user conversion by simplifying the signup process. You can learn more about Appwrite's other OAuth2 providers [here](placeholder link). | ||
|
|
||
| ## Enabling the Zoom provider | ||
| Before you can use Zoom to authenticate users, you need to enable the provider in your Appwrite console. | ||
| 1. Navigate to your Appwrite project | ||
| 2. Navigate to **Auth** > **Settings** | ||
| 3. Find and open the OAuth provider | ||
| 4. In the **Zoom OAuth2 Settings** modal, use the toggle to enable the provider | ||
|
|
||
| Don't close this modal, we'll need to create a Zoom OAuth app in Zoom App Marketplace to complete this form. | ||
|
|
||
| ## Creating a Zoom app for OAuth | ||
| To establish Zoom OAuth integration with Appwrite, start by creating a Zoom OAuth app via your [Zoom App Marketplace Dashboard](https://marketplace.zoom.us/user/build). In the navigation bar, access the **Build App** menu and opt for an OAuth app. Assign a suitable name to your app and proceed with its creation. In the **App Credentials** section, When prompted to provide a **Redirect URI**, , provide the **URI** found in the **Zoom OAuth2 Settings** modal from your Appwrite console. Also include your domain name in the designated allow list. In the **Information** section, add basic app information and developer contact information. Add all necessary scopes for your app in **Scopes** section. | ||
|
|
||
| After you've created your Zoom OAuth app, you can head back to your Appwrite console to complete the form in the **Zoom OAuth2 Settings** modal. | ||
| - You can find the **Client ID** in your Zoom OAuth app credentials and provide this in the **App ID** field in the **Zoom OAuth2 Settings** modal from the Appwrite console. | ||
| - Your app's **Client Secret** is in the designated field under app credentials. | ||
| - Copy the client secret and provide this in the **App Secret** field in the **Zoom OAuth2 Settings** modal from the Appwrite console. | ||
|
|
||
| ## Authenticating | ||
| You can use any of the Appwrite Client SDKs to authenticate users with their Zoom account. | ||
|
|
||
| ### Web | ||
| When a user calls the [Create OAuth2 Session](https://appwrite.io/docs/client/account#accountCreateOAuth2Session) endpoint in your web app, they will be taken to Zoom's OAuth page to complete their login. | ||
|
|
||
| After authenticating, they'll be redirected back to your app using either the `success` or `failure` URLs provided. To provide the best experience to your users, make sure to **implement and provide both routes** to prompt the user about successful and failed authentication attempts. | ||
|
|
||
| ```js | ||
| import { Client, Account } from "appwrite"; | ||
|
|
||
| const client = new Client(); | ||
|
|
||
| const account = new Account(client); | ||
|
|
||
| client | ||
| .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint | ||
| .setProject('[PROJECT_ID]') // Your Project ID | ||
| ; | ||
|
|
||
| // Go to Zoom OAuth login page | ||
| account.createOAuth2Session('zoom', '[LINK_ON_SUCCESS]', '[LINK_ON_FAILURE]'); | ||
| ``` | ||
|
|
||
| ### Flutter | ||
| You can use OAuth in your Flutter application, but some platforms like Android and Apple requires additional configuration to enable the OAuth callback, so that users can be redirected back to your app. | ||
|
|
||
| #### Android OAuth callback | ||
|
|
||
| In order to capture the Appwrite OAuth callback url, the following activity needs to be added inside the `<application>` tag, along side the existing `<activity>` tags in your `AndroidManifest.xml`. Be sure to replace the `[PROJECT_ID]` string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in your Appwrite console. | ||
|
|
||
| ```xml | ||
| <manifest ...> | ||
| ... | ||
| <application ...> | ||
| ... | ||
| <!-- Add this inside the `<application>` tag, along side the existing `<activity>` tags --> | ||
| <activity android:name="io.appwrite.views.CallbackActivity" android:exported="true"> | ||
| <intent-filter android:label="android_web_auth"> | ||
| <action android:name="android.intent.action.VIEW" /> | ||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
| <data android:scheme="appwrite-callback-[PROJECT_ID]" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
| </manifest> | ||
| ``` | ||
|
|
||
| #### Apple | ||
|
|
||
| In order to capture the Appwrite OAuth callback url, the following URL scheme needs to added to your `Info.plist`. Be sure to replace the `[PROJECT_ID]` string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in your Appwrite console. | ||
|
|
||
| ```xml | ||
| <key>CFBundleURLTypes</key> | ||
| <array> | ||
| <dict> | ||
| <key>CFBundleTypeRole</key> | ||
| <string>Editor</string> | ||
| <key>CFBundleURLName</key> | ||
| <string>io.appwrite</string> | ||
| <key>CFBundleURLSchemes</key> | ||
| <array> | ||
| <string>appwrite-callback-[PROJECT_ID]</string> | ||
| </array> | ||
| </dict> | ||
| </array> | ||
| ``` | ||
|
|
||
| To authenticate a user in your Flutter application, use the [Create OAuth2 Session](https://appwrite.io/docs/client/account?sdk=flutter-default#accountCreateOAuth2Session) endpoint. | ||
|
|
||
| ```dart | ||
| import 'package:appwrite/appwrite.dart'; | ||
|
|
||
| void main() async { | ||
| final client = new Client(); | ||
| final account = new Account(client); | ||
|
|
||
| client | ||
| .setEndpoint('https://cloud.appwrite.io/v1') // YOUR API Endpoint | ||
| .setProject('[PROJECT_ID]') // YOUR PROJECT ID | ||
| ; | ||
|
|
||
| // OAuth Login, for simplest implementation you can leave both success and | ||
| // failure link empty so that Appwrite handles everything. | ||
| await account.createOAuth2Session(provider: 'zoom'); | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
| ### Android (Kotlin) | ||
| Before you can add OAuth to your Android app, you need to setup a callback for your OAuth flow. | ||
|
|
||
| In order to capture the Appwrite OAuth callback url, the following activity needs to be added inside the `<application>` tag, along side the existing `<activity>` tags in your `AndroidManifest.xml`. Be sure to replace the `[PROJECT_ID]` string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in your Appwrite console. | ||
|
|
||
| ```xml | ||
| <manifest ...> | ||
| ... | ||
| <application ...> | ||
| ... | ||
| <!-- Add this inside the `<application>` tag, along side the existing `<activity>` tags --> | ||
| <activity android:name="io.appwrite.views.CallbackActivity" android:exported="true"> | ||
| <intent-filter android:label="android_web_auth"> | ||
| <action android:name="android.intent.action.VIEW" /> | ||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
| <data android:scheme="appwrite-callback-[PROJECT_ID]" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
| </manifest> | ||
| ``` | ||
|
|
||
| To authenticate a user in your Android application, use the [Create OAuth2 Session](https://appwrite.io/docs/client/account?sdk=android-kotlin#accountCreateOAuth2Session) endpoint. | ||
|
|
||
| ```kotlin | ||
| import io.appwrite.Client | ||
| import io.appwrite.services.Account | ||
|
|
||
| val client = Client(context) | ||
| .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("[PROJECT_ID]") // Your Project ID | ||
|
|
||
| val account = Account(client) | ||
|
|
||
| account.createOAuth2Session(provider = "zoom") | ||
| ``` | ||
|
|
||
| ### Android (Java) | ||
| Before you can add OAuth to your Android app, you need to setup a callback for your OAuth flow. | ||
|
|
||
| In order to capture the Appwrite OAuth callback url, the following activity needs to be added inside the `<application>` tag, along side the existing `<activity>` tags in your `AndroidManifest.xml`. Be sure to replace the `[PROJECT_ID]` string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in your Appwrite console. | ||
|
|
||
| ```xml | ||
| <manifest ...> | ||
| ... | ||
| <application ...> | ||
| ... | ||
| <!-- Add this inside the `<application>` tag, along side the existing `<activity>` tags --> | ||
| <activity android:name="io.appwrite.views.CallbackActivity" android:exported="true"> | ||
| <intent-filter android:label="android_web_auth"> | ||
| <action android:name="android.intent.action.VIEW" /> | ||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
| <data android:scheme="appwrite-callback-[PROJECT_ID]" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
| </manifest> | ||
| ``` | ||
|
|
||
| To authenticate a user in your Android application, use the [Create OAuth2 Session](https://appwrite.io/docs/client/account?sdk=android-java#accountCreateOAuth2Session) endpoint. | ||
|
|
||
| ```java | ||
| import io.appwrite.Client; | ||
| import io.appwrite.coroutines.CoroutineCallback; | ||
| import io.appwrite.services.Account; | ||
|
|
||
| Client client = new Client(context) | ||
| .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("[PROJECT_ID]"); // Your Project ID | ||
|
|
||
| Account account = new Account(client); | ||
|
|
||
| account.createOAuth2Session( | ||
| "zoom", | ||
| new CoroutineCallback<>((result, error) -> { | ||
| if (error != null) { | ||
| error.printStackTrace(); | ||
| return; | ||
| } | ||
|
|
||
| Log.d("Appwrite", result.toString()); | ||
| }) | ||
| ); | ||
| ``` | ||
|
|
||
| ### iOS (Swift) | ||
| In order to capture the Appwrite OAuth callback url, the following URL scheme needs to added to your `Info.plist`. Be sure to replace the `[PROJECT_ID]` string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in your Appwrite console. | ||
|
|
||
| ```xml | ||
| <key>CFBundleURLTypes</key> | ||
| <array> | ||
| <dict> | ||
| <key>CFBundleTypeRole</key> | ||
| <string>Editor</string> | ||
| <key>CFBundleURLName</key> | ||
| <string>io.appwrite</string> | ||
| <key>CFBundleURLSchemes</key> | ||
| <array> | ||
| <string>appwrite-callback-[PROJECT_ID]</string> | ||
| </array> | ||
| </dict> | ||
| </array> | ||
| ``` | ||
|
|
||
| If you're using UIKit, you'll also need to add a hook to your `SceneDelegate.swift` file to ensure cookies work correctly. | ||
| ```swift | ||
| func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { | ||
| guard let url = URLContexts.first?.url, | ||
| url.absoluteString.contains("appwrite-callback") else { | ||
| return | ||
| } | ||
| WebAuthComponent.handleIncomingCookie(from: url) | ||
| } | ||
| ``` | ||
|
|
||
| To authenticate a user in your iOS application, use the [Create OAuth2 Session](https://appwrite.io/docs/client/account?sdk=apple-default#accountCreateOAuth2Session) endpoint. | ||
|
|
||
| ```swift | ||
| import Appwrite | ||
|
|
||
| let client = Client() | ||
| .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("[PROJECT_ID]") // Your Project ID | ||
|
|
||
| let account = Account(client) | ||
|
|
||
| let success = try await account.createOAuth2Session(provider: "zoom") | ||
| ``` | ||
|
|
||
| ## Refreshing the OAuth2 session | ||
| OAuth2 sessions expire to protect from security risks. This means, OAuth2 sessions should be refreshed to keep the user authenticated. You can do this by calling the [Update OAuth Session](https://appwrite.io/docs/client/account#accountUpdateSession) endpoint when ever your user visits your app. | ||
|
|
||
| ### Web | ||
| ```js | ||
| import { Client, Account } from "appwrite"; | ||
|
|
||
| const client = new Client(); | ||
|
|
||
| const account = new Account(client); | ||
|
|
||
| client | ||
| .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint | ||
| .setProject('[PROJECT_ID]') // Your Project ID | ||
| ; | ||
|
|
||
| // Updates current session | ||
| const promise = account.updateSession('current'); | ||
|
|
||
| promise.then(function (response) { | ||
| console.log(response); // Success | ||
| }, function (error) { | ||
| console.log(error); // Failure | ||
| }); | ||
| ``` | ||
|
|
||
| ### Flutter | ||
| ```dart | ||
| import 'package:appwrite/appwrite.dart'; | ||
|
|
||
| void main() async { | ||
| final client = new Client(); | ||
| final account = new Account(client); | ||
|
|
||
| client | ||
| .setEndpoint('https://cloud.appwrite.io/v1') // YOUR API Endpoint | ||
| .setProject('[PROJECT_ID]'); // YOUR PROJECT ID | ||
|
|
||
| // Simplest implementation of updating an OAuth2 session | ||
| // prints Session Object value on success and error message on failure | ||
| try { | ||
| final future = await account.updateSession(sessionId: 'current'); | ||
| print(future.toMap()); // Success | ||
| } on AppwriteException catch(e){ | ||
| print(e.message); // Failure | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Android (Kotlin) | ||
| ```kotlin | ||
| import io.appwrite.Client | ||
| import io.appwrite.services.Account | ||
|
|
||
| val client = Client(context) | ||
| .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("[PROJECT_ID]") // Your Project ID | ||
|
|
||
| val account = Account(client) | ||
|
|
||
| val response = account.updateSession(sessionId = "current") | ||
| ``` | ||
|
|
||
| ### Android (Java) | ||
| ```java | ||
| import io.appwrite.Client; | ||
| import io.appwrite.coroutines.CoroutineCallback; | ||
| import io.appwrite.services.Account; | ||
|
|
||
| Client client = new Client(context) | ||
| .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("[PROJECT_ID]"); // Your Project ID | ||
|
|
||
| Account account = new Account(client); | ||
|
|
||
| account.updateSession( | ||
| "current" | ||
| new CoroutineCallback<>((result, error) -> { | ||
| if (error != null) { | ||
| error.printStackTrace(); | ||
| return; | ||
| } | ||
|
|
||
| Log.d("Appwrite", result.toString()); | ||
| }) | ||
| ); | ||
| ``` | ||
|
|
||
| ### iOS (Swift) | ||
| ``` swift | ||
| import Appwrite | ||
|
|
||
| let client = Client() | ||
| .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
| .setProject("[PROJECT_ID]") // Your Project ID | ||
|
|
||
| let account = Account(client) | ||
|
|
||
| let session = try await account.updateSession(sessionId: "current") | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find the Client ID in your Zoom OAuth app credentials. Provide this in the Appwrite console's Zoom OAuth2 Settings modal, in the App ID field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! @Haimantika changing it accordingly.