ログインの繰り返しを処理する

Classroom アドオンに関する 3 件目のチュートリアルです 説明します。

このチュートリアルでは、アドオンへの繰り返しアクセスを 以前に付与された認証情報を取得する。その後、ユーザーを すぐに API リクエストを発行できるページ。必須項目です 動作を変更することもできます。

このチュートリアルでは、次のことを行います。

  • ユーザー認証情報用の永続ストレージを実装する。
  • login_hint アドオン クエリ パラメータを取得して評価します。これは ログイン ユーザーの一意の Google ID 番号。
で確認できます。

完了したら、ウェブアプリでユーザーを完全に認証して、 Google API

iframe クエリ パラメータについて

Classroom により、アドオンの添付ファイルの設定 URI が あります。クラスルーム URI の末尾に複数の GET クエリ パラメータを追加します。役に立つリソースが含まれている コンテキスト情報を提供します。たとえば、添付ファイルの検出 URI が https://example.com/addon を指定すると、Classroom で ソース URL を https://example.com/addon?courseId=XXX&itemId=YYY&itemType=courseWork&addOnToken=ZZZ, ここで、XXXYYYZZZ は文字列 ID です。詳しくは、iframe ガイドをご覧ください。 詳しく説明します

検出 URL では、次の 5 つのクエリ パラメータを使用できます。

  • courseId: 現在の Classroom コースの ID。
  • itemId: ユーザーが編集または作成するストリーム アイテムの ID。
  • itemType: ユーザーが作成または編集しているストリーム アイテムの種類。次のいずれかです。 courseWorkcourseWorkMaterial、または announcement
  • addOnToken: 特定のものを承認するために使用されるトークン Classroom アドオンのアクション。
  • login_hint: 現在のユーザーの Google ID。
で確認できます。

このチュートリアルでは、login_hint について説明します。ユーザーのルーティングは クエリ パラメータは、存在しない場合は承認フローに、または アドオンの検出ページが存在する場合は、それを表示することもできます。

クエリ パラメータにアクセスする

クエリ パラメータは URI 文字列でウェブ アプリケーションに渡されます。保存 これらの値をセッションで使用すると認証フローで使用され、 ユーザーに関する情報を保存および取得します。これらのクエリ パラメータは、 アドオンが最初に開いたときに渡されます。

Python

Flask のルート定義に移動します(routes.py 例をご覧ください)。アドオンのランディング ルートの先頭 (この例では /classroom-addon)、 login_hint クエリ パラメータ:

# If the login_hint query parameter is available, we'll store it in the session.
if flask.request.args.get("login_hint"):
    flask.session["login_hint"] = flask.request.args.get("login_hint")

login_hint(存在する場合)がセッションに保存されていることを確認します。これは 値の格納に適した場所エフェメラルなものであり 新しい値が表示されます。

# It's possible that we might return to this route later, in which case the
# parameters will not be passed in. Instead, use the values cached in the
# session.
login_hint = flask.session.get("login_hint")

# If there's still no login_hint query parameter, this must be their first
# time signing in, so send the user to the sign in page.
if login_hint is None:
    return start_auth_flow()

Java

コントローラ クラスのアドオンのランディング ルートに移動する (この例では AuthController.java/addon-discovery)。ちなみに login_hint クエリを取得して保存する パラメータを指定します。

/** Retrieve the login_hint or hd query parameters from the request URL. */
String login_hint = request.getParameter("login_hint");
String hd = request.getParameter("hd");

login_hint(存在する場合)がセッションに保存されていることを確認します。これは 値の格納に適した場所エフェメラルなものであり 新しい値が表示されます。

/** If neither query parameter is sent, use the values in the session. */
if (login_hint == null && hd == null) {
    login_hint = (String) session.getAttribute("login_hint");
    hd = (String) session.getAttribute("hd");
}

/** If the hd query parameter is provided, add hd to the session and route
*   the user to the authorization page. */
else if (hd != null) {
    session.setAttribute("hd", hd);
    return startAuthFlow(model);
}

/** If the login_hint query parameter is provided, add it to the session. */
else if (login_hint != null) {
    session.setAttribute("login_hint", login_hint);
}

クエリ パラメータを承認フローに追加する

login_hint パラメータを Google の認証サーバーに渡す できます。これにより、認証プロセスが容易になります。アプリケーションが サーバーはヒントを使用して ログイン フォームのメールアドレス フィールドに事前入力されます。

Python

Flask サーバー ファイル(/authorize)の承認ルートに移動します。 をご覧ください)。login_hint 引数を flow.authorization_url

authorization_url, state = flow.authorization_url(
    # Enable offline access so that you can refresh an access token without
    # re-prompting the user for permission. Recommended for web server apps.
    access_type="offline",
    # Enable incremental authorization. Recommended as a best practice.
    include_granted_scopes="true",
    # The user will automatically be selected if we have the login_hint.
    login_hint=flask.session.get("login_hint"),

Java

AuthService.java クラスの authorize() メソッドに移動します。追加 メソッドにパラメータとして login_hinthd を追加し、login_hint を追加します。 と hd 引数を認証 URL 生成ツールに渡します。

String authUrl = flow
    .newAuthorizationUrl()
    .setState(state)
    .set("login_hint", login_hint)
    .set("hd", hd)
    .setRedirectUri(REDIRECT_URI)
    .build();

ユーザー認証情報用の永続ストレージを追加する

アドオンの読み込み時にクエリ パラメータとして login_hint を受け取った場合、それは ユーザーが Google アカウントの認証フローを 説明します。以前の認証情報を取得すれば、強制的に 再度ログインする必要があります。

トレーニングの完了時に更新トークンを受け取ったことを思い出してください。 承認フローを実行しますこのトークンを保存します。アクセス トークンを取得するために再利用される これは有効期間が短く、Google API を使用するために必要です。以前に保存しました 認証情報を保存しておかなければなりませんが、 再訪問に対応できます

ユーザー スキーマを定義してデータベースを設定する

User のデータベース スキーマを設定します。

Python

ユーザー スキーマを定義する

User には次の属性が含まれます。

  • id: ユーザーの Google ID。これは、 login_hint クエリ パラメータ。
  • display_name: ユーザーの姓名(「Alex Smith」など)。
  • email: ユーザーのメールアドレス。
  • portrait_url: ユーザーのプロフィール写真の URL。
  • refresh_token: 以前に取得した更新トークン。
で確認できます。

この例では、SQLite を使用してストレージを実装しています。SQLite は、 Python。flask_sqlalchemy モジュールを使用して、データベースを円滑に処理します。 あります。

データベースの設定

まず、データベースのファイルの場所を指定します。サーバーに移動する 構成ファイル(この例では config.py)を作成し、 できます。

import os

# Point to a database file in the project root.
DATABASE_FILE_NAME = os.path.join(
    os.path.abspath(os.path.dirname(__file__)), 'data.sqlite')

class Config(object):
    SQLALCHEMY_DATABASE_URI = f"sqlite:///{DATABASE_FILE_NAME}"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

これにより、Flask がローカル ファイルと同じディレクトリにある data.sqlite ファイルを main.py ファイル。

次に、モジュール ディレクトリに移動して、新しい models.py ファイルを作成します。 上記の例に従っている場合、これは webapp/models.py です。追加 次のコードを新しいファイルに追加して User テーブルを定義します。 webapp のモジュール名(異なる場合)。

from webapp import db

# Database model to represent a user.
class User(db.Model):
    # The user's identifying information:
    id = db.Column(db.String(120), primary_key=True)
    display_name = db.Column(db.String(80))
    email = db.Column(db.String(120), unique=True)
    portrait_url = db.Column(db.Text())

    # The user's refresh token, which will be used to obtain an access token.
    # Note that refresh tokens will become invalid if:
    # - The refresh token has not been used for six months.
    # - The user revokes your app's access permissions.
    # - The user changes passwords.
    # - The user belongs to a Google Cloud organization
    #   that has session control policies in effect.
    refresh_token = db.Column(db.Text())

最後に、モジュールの __init__.py ファイルに以下を追加してインポートします。 データベースを作成します

from webapp import models
from os import path
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy(app)

# Initialize the database file if not created.
if not path.exists(config.DATABASE_FILE_NAME):
    db.create_all()

Java

ユーザー スキーマを定義する

User には次の属性が含まれます。

  • id: ユーザーの Google ID。この値は、 login_hint クエリ パラメータ。
  • email: ユーザーのメールアドレス。
で確認できます。

モジュールの resources ディレクトリに schema.sql ファイルを作成します。春 はこのファイルを読み取って、それに応じてデータベースのスキーマを生成します。 テーブル名、users、表す列を使用してテーブルを定義する User 属性 idemail

CREATE TABLE IF NOT EXISTS users (
    id VARCHAR(255) PRIMARY KEY, -- user's unique Google ID
    email VARCHAR(255), -- user's email address
);

データベースの User モデルを定義する Java クラスを作成します。これは、 上記の例では User.java です。

@Entity アノテーションを追加して、これが可能な POJO であることを示します。 データベースに保存されます@Table アノテーションを schema.sql で構成した対応するテーブル名。

コードサンプルには、2 つのオブジェクトのコンストラクタとセッターが含まれていることに注意してください。 属性です。コンストラクタとセッターは、 データベースでユーザーを作成または更新する AuthController.java。マイページ 必要に応じてゲッターや toString メソッドを含めることもできますが、 このチュートリアルでは、これらのメソッドは使用されないため、 わかりやすくするために、このページのコードサンプルを使用します。

/** An entity class that provides a model to store user information. */
@Entity
@Table(name = "users")
public class User {
    /** The user's unique Google ID. The @Id annotation specifies that this
     *   is the primary key. */
    @Id
    @Column
    private String id;

    /** The user's email address. */
    @Column
    private String email;

    /** Required User class no args constructor. */
    public User() {
    }

    /** The User class constructor that creates a User object with the
    *   specified parameters.
    *   @param id the user's unique Google ID
    *   @param email the user's email address
    */
    public User(String id, String email) {
        this.id = id;
        this.email = email;
    }

    public void setId(String id) { this.id = id; }

    public void setEmail(String email) { this.email = email; }
}

CRUD オペレーションを処理する UserRepository.java というインターフェースを作成する データベースにエクスポートします。このインターフェースは、CrudRepository インターフェースを拡張します。

/** Provides CRUD operations for the User class by extending the
 *   CrudRepository interface. */
@Repository
public interface UserRepository extends CrudRepository<User, String> {
}

コントローラ クラスは、クライアントとサーバー間の通信を容易にします。 できます。そのため、コントローラ クラスのコンストラクタを更新して、 UserRepository クラス。

/** Declare UserRepository to be used in the Controller class constructor. */
private final UserRepository userRepository;

/**
*   ...
*   @param userRepository the class that interacts with User objects stored in
*   persistent storage.
*/
public AuthController(AuthService authService, UserRepository userRepository) {
    this.authService = authService;
    this.userRepository = userRepository;
}

データベースの設定

ユーザー関連の情報を保存するには、H2 データベースに本質的に サポートされていますこのデータベースは、後続の チュートリアルに沿って、他の Classroom 関連の他の 情報です。H2 データベースを設定するには、以下を追加する必要があります application.properties に追加します。

# Enable configuration for persistent storage using an H2 database
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:./h2/userdb
spring.datasource.username=<USERNAME>
spring.datasource.password=<PASSWORD>
spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false

spring.datasource.url 構成ファイルは h2 というディレクトリを作成し、 その中に保存されている userdb というファイルです。H2 データベースにパスを追加して、 .gitignorespring.datasource.usernamespring.datasource.password後に、アプリケーションを実行して 任意のユーザー名とパスワードでデータベースを作成できます。更新するには、 ユーザー名とパスワードを使用してログインし、 生成された h2 ディレクトリを削除し、構成を更新する アプリケーションを再実行します。

spring.jpa.hibernate.ddl-auto 構成を update に設定すると、 データベースに保存されているデータは、アプリケーションを再起動しても保持されます。 アプリケーションを再起動するたびにデータベースをクリアするには、 config を create に設定します。

spring.jpa.open-in-view 構成を false に設定します。この構成は有効です パフォーマンスの問題が発生する可能性があり、 本番環境での診断は困難です

前述のように、Google Cloud のアプリケーションの認証情報を リピーターです。これは、組み込みの認証情報ストアによって促進されます。 GoogleAuthorizationCodeFlowが提供するサポートです

AuthService.java クラスで、ファイルが読み込まれるファイルへのパスを 認証情報クラスが保存されます。この例では、ファイルは /credentialStore ディレクトリ。認証情報ストアへのパスを .gitignore。このディレクトリは、ユーザーがアプリケーションの 承認フローを実行します

private static final File dataDirectory = new File("credentialStore");

次に、AuthService.java ファイルにメソッドを作成して、 FileDataStoreFactory オブジェクトを返します。これは、Pod が存在する 認証情報を保存します。

/** Creates and returns FileDataStoreFactory object to store credentials.
 *   @return FileDataStoreFactory dataStore used to save and obtain users ids
 *   mapped to Credentials.
 *   @throws IOException if creating the dataStore is unsuccessful.
 */
public FileDataStoreFactory getCredentialDataStore() throws IOException {
    FileDataStoreFactory dataStore = new FileDataStoreFactory(dataDirectory);
    return dataStore;
}

AuthService.javagetFlow() メソッドを更新して以下を含めます。 setDataStoreFactoryGoogleAuthorizationCodeFlow Builder()) メソッドを呼び出し、getCredentialDataStore() を呼び出してデータストアを設定します。

GoogleAuthorizationCodeFlow authorizationCodeFlow =
    new GoogleAuthorizationCodeFlow.Builder(
        HTTP_TRANSPORT,
        JSON_FACTORY,
        getClientSecrets(),
        getScopes())
    .setAccessType("offline")
    .setDataStoreFactory(getCredentialDataStore())
    .build();

次に、getAndSaveCredentials(String authorizationCode) メソッドを更新します。 以前は、この方法では認証情報を保存せずに認証情報を取得していました。 できます。認証情報をデータストアに格納するようにメソッドを更新する ユーザー ID でインデックス付けされます。

ユーザー ID は、TokenResponse オブジェクトから id_token ですが、最初に確認する必要があります。それ以外の場合、 アプリケーションがユーザーになりすますために、変更されたユーザー サーバーに送ります。Google API クライアントを使用して id_token を検証するためのライブラリが含まれています。詳細については、[Google Identity のページ Google ID トークンの確認] をご覧ください。

// Obtaining the id_token will help determine which user signed in to the application.
String idTokenString = tokenResponse.get("id_token").toString();

// Validate the id_token using the GoogleIdTokenVerifier object.
GoogleIdTokenVerifier googleIdTokenVerifier = new GoogleIdTokenVerifier.Builder(
        HTTP_TRANSPORT,
        JSON_FACTORY)
    .setAudience(Collections.singletonList(
        googleClientSecrets.getWeb().getClientId()))
    .build();

GoogleIdToken idToken = googleIdTokenVerifier.verify(idTokenString);

if (idToken == null) {
    throw new Exception("Invalid ID token.");
}

id_token が検証されたら、userId を取得して保存します。 認証情報を取得します。

// Obtain the user id from the id_token.
Payload payload = idToken.getPayload();
String userId = payload.getSubject();

flow.createAndStoreCredential の呼び出しを更新して userId を含めます。

// Save the user id and credentials to the configured FileDataStoreFactory.
Credential credential = flow.createAndStoreCredential(tokenResponse, userId);

認証情報を返すメソッドを AuthService.java クラスに追加する 特定のユーザーがデータストアに存在する場合は、そのユーザーのアカウントを取得します。

/** Find credentials in the datastore based on a specific user id.
*   @param userId key to find in the file datastore.
*   @return Credential object to be returned if a matching key is found in the datastore. Null if
*   the key doesn't exist.
*   @throws Exception if building flow object or checking for userId key is unsuccessful. */
public Credential loadFromCredentialDataStore(String userId) throws Exception {
    try {
        GoogleAuthorizationCodeFlow flow = getFlow();
        Credential credential = flow.loadCredential(userId);
        return credential;
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}

認証情報を取得する

Users を取得するためのメソッドを定義します。idlogin_hint クエリ パラメータ。特定のユーザーを取得するために使用できます。 記録します。

Python

def get_credentials_from_storage(id):
    """
    Retrieves credentials from the storage and returns them as a dictionary.
    """
    return User.query.get(id)

Java

AuthController.java クラスで、ユーザーを取得するメソッドを定義します。 自動的に取得されます。

/** Retrieves stored credentials based on the user id.
*   @param id the id of the current user
*   @return User the database entry corresponding to the current user or null
*   if the user doesn't exist in the database.
*/
public User getUser(String id) {
    if (id != null) {
        Optional<User> user = userRepository.findById(id);
        if (user.isPresent()) {
            return user.get();
        }
    }
    return null;
}

認証情報を保存する

認証情報を保存するシナリオは 2 つあります。ユーザーの id がすでに 既存のレコードを新しい値で更新します。それ以外の場合は 新しい User レコードを作成してデータベースに追加する。

Python

まず、storage または update を実行するユーティリティ メソッドを 確認します。

def save_user_credentials(credentials=None, user_info=None):
    """
    Updates or adds a User to the database. A new user is added only if both
    credentials and user_info are provided.

    Args:
        credentials: An optional Credentials object.
        user_info: An optional dict containing user info returned by the
            OAuth 2.0 API.
    """

    existing_user = get_credentials_from_storage(
        flask.session.get("login_hint"))

    if existing_user:
        if user_info:
            existing_user.id = user_info.get("id")
            existing_user.display_name = user_info.get("name")
            existing_user.email = user_info.get("email")
            existing_user.portrait_url = user_info.get("picture")

        if credentials and credentials.refresh_token is not None:
            existing_user.refresh_token = credentials.refresh_token

    elif credentials and user_info:
        new_user = User(id=user_info.get("id"),
                        display_name=user_info.get("name"),
                        email=user_info.get("email"),
                        portrait_url=user_info.get("picture"),
                        refresh_token=credentials.refresh_token)

        db.session.add(new_user)

    db.session.commit()

認証情報を Google Workspace アカウントに保存する方法は 2 つあります。 データベース: アプリケーションの終了時に API 呼び出しを発行するときに使用されます。そこで セッションの credentials キーを設定しています。

callbackのルートの最後で save_user_credentials に通報します。現在の user_info オブジェクトを使用します。

# The flow is complete! We'll use the credentials to fetch the user's info.
user_info_service = googleapiclient.discovery.build(
    serviceName="oauth2", version="v2", credentials=credentials)

user_info = user_info_service.userinfo().get().execute()

flask.session["username"] = user_info.get("name")

save_user_credentials(credentials, user_info)

また、API の呼び出し後に認証情報を更新する必要もあります。この その場合は、更新された認証情報を引数として save_user_credentials メソッドを使用します。

# Save credentials in case access token was refreshed.
flask.session["credentials"] = credentials_to_dict(credentials)
save_user_credentials(credentials)

Java

まず、User オブジェクトを保存または更新するメソッドを H2 データベースです

/** Adds or updates a user in the database.
*   @param credential the credentials object to save or update in the database.
*   @param userinfo the userinfo object to save or update in the database.
*   @param session the current session.
*/
public void saveUser(Credential credential, Userinfo userinfo, HttpSession session) {
    User storedUser = null;
    if (session != null && session.getAttribute("login_hint") != null) {
        storedUser = getUser(session.getAttribute("login_hint").toString());
    }

    if (storedUser != null) {
        if (userinfo != null) {
            storedUser.setId(userinfo.getId());
            storedUser.setEmail(userinfo.getEmail());
        }
        userRepository.save(storedUser);
    } else if (credential != null && userinfo != null) {
        User newUser = new User(
            userinfo.getId(),
            userinfo.getEmail(),
        );
        userRepository.save(newUser);
    }
}

認証情報を Google Workspace アカウントに保存する方法は 2 つあります。 データベース: アプリケーションの終了時に API 呼び出しを発行するときに使用されます。そこで セッションの credentials キーを設定しています。

/callback ルートの最後で saveUser を呼び出します。以前の user_info オブジェクトを使用します。

/** This is the end of the auth flow. We should save user info to the database. */
Userinfo userinfo = authService.getUserInfo(credentials);
saveUser(credentials, userinfo, session);

また、API の呼び出し後に認証情報を更新する必要もあります。この その場合は、更新された認証情報を saveUser の引数として指定できます。 メソッドを呼び出します。

/** Save credentials in case access token was refreshed. */
saveUser(credentials, null, session);

期限切れの認証情報

更新トークンが無効になる理由はいくつかあります。以下の内容が含まれます。

  • 更新トークンが 6 か月間使用されていない。
  • ユーザーがアプリのアクセス権を取り消した。
  • ユーザーがパスワードを変更する。
  • ユーザーが、セッション管理を行う Google Cloud 組織に属している あります。

次の場合は、ユーザーを認証フローに再度送信して、新しいトークンを取得します。 認証情報が無効になった場合です

ユーザーを自動的にルーティングする

アドオンのランディング ルートを変更して、ユーザーが以前に承認したかどうかを検出する 確認します。その場合は、メインのアドオンページをご案内してください。それ以外の場合は、 ログインしてもらう必要があります。

Python

アプリケーションの作成時にデータベース ファイルが作成されていることを確認します。 説明します。モジュール初期化子( webapp/__init__.py)、またはメイン メソッドで サーバーを起動します。

# Initialize the database file if not created.
if not os.path.exists(DATABASE_FILE_NAME):
    db.create_all()

このメソッドは、login_hint クエリ パラメータを次のように処理する必要があります。 上記をご覧ください。これが繰り返される場合は、ストアの認証情報を読み込みます。 できます。「login_hint」を受信した場合は、リピーターであることがわかります。 このユーザーに保存されている認証情報を取得し、 あります。

stored_credentials = get_credentials_from_storage(login_hint)

# If we have stored credentials, store them in the session.
if stored_credentials:
    # Load the client secrets file contents.
    client_secrets_dict = json.load(
        open(CLIENT_SECRETS_FILE)).get("web")

    # Update the credentials in the session.
    if not flask.session.get("credentials"):
        flask.session["credentials"] = {}

    flask.session["credentials"] = {
        "token": stored_credentials.access_token,
        "refresh_token": stored_credentials.refresh_token,
        "token_uri": client_secrets_dict["token_uri"],
        "client_id": client_secrets_dict["client_id"],
        "client_secret": client_secrets_dict["client_secret"],
        "scopes": SCOPES
    }

    # Set the username in the session.
    flask.session["username"] = stored_credentials.display_name

最後に、ユーザー ID が不明な場合、ユーザーをログインページに誘導します。 認証情報が必要です。必要な場合は、メインのアドオンページをご案内します。

if "credentials" not in flask.session or \
    flask.session["credentials"]["refresh_token"] is None:
    return flask.render_template("authorization.html")

return flask.render_template(
    "addon-discovery.html",
    message="You've reached the addon discovery page.")

Java

アドオンのランディング ルート(/addon-discovery 例です)。前述のように、ここで login_hint を処理しました。 クエリ パラメータを指定します。

まず、セッションに認証情報が存在するかどうかを確認します。そうでない場合は、 startAuthFlow メソッドを呼び出して、認証フローでユーザーにアクセスできます。

/** Check if the credentials exist in the session. The session could have
 *   been cleared when the user clicked the Sign-Out button, and the expected
 *   behavior after sign-out would be to display the sign-in page when the
 *   iframe is opened again. */
if (session.getAttribute("credentials") == null) {
    return startAuthFlow(model);
}

次に、リピーターの場合は、H2 データベースからユーザーを読み込みます。です。 login_hint クエリ パラメータを受け取った場合、リピート訪問者とみなされます。もし H2 データベースに存在する場合、credential から認証情報を読み込みます。 以前に設定したデータストア」を確認し、セッションで認証情報を設定します。もし 認証情報データストアから認証情報が取得されていない場合は、 startAuthFlow を呼び出して、認証フローで処理します。

/** At this point, we know that credentials exist in the session, but we
 *   should update the session credentials with the credentials in persistent
 *   storage in case they were refreshed. If the credentials in persistent
 *   storage are null, we should navigate the user to the authorization flow
 *   to obtain persisted credentials. */

User storedUser = getUser(login_hint);

if (storedUser != null) {
    Credential credential = authService.loadFromCredentialDataStore(login_hint);
    if (credential != null) {
        session.setAttribute("credentials", credential);
    } else {
        return startAuthFlow(model);
    }
}

最後に、ユーザーをアドオンのランディング ページに転送します。

/** Finally, if there are credentials in the session and in persistent
 *   storage, direct the user to the addon-discovery page. */
return "addon-discovery";

アドオンをテストする

Google Classroom教師向けのテスト用の 1 つとしてログインする できます。[授業] タブに移動し、新しい課題を作成します。[ テキスト領域の下にある [アドオン] ボタンをクリックし、アドオンを選択します。iframe が開き、アドオンが 添付ファイルのセットアップ URI。 Google Workspace Marketplace SDK の [アプリの構成] ページ。

これで、次のステップ(添付ファイルの作成)に進む準備が整いました ユーザーロールを特定します