@grepvine/sdk
    Preparing search index...

    Class DeviceLogin

    Logging in devices by approval, reached as client.deviceLogin.

    A device calls DeviceLogin.authorize (or start and poll) and shows a code; a person approves it with approve from a client that holds a session or an API key, and the device receives an API key of its own.

    Hierarchy

    • DeviceLogin
      • DeviceLogin
    Index
    • Log in this device: start a login, report it through onCode, and poll at the service's interval, slowing down when asked, until the key is issued.

      A denied login throws InvalidRequestError with code "access_denied". A login that expires, or outlasts timeout milliseconds, throws GrepvineError.

      const { key } = await client.deviceLogin.authorize({
      apiKeyName: "build agent",
      onCode: ({ user_code, verification_uri_complete }) =>
      console.log(`Open ${verification_uri_complete} and enter ${user_code}`),
      });

      Parameters

      • parameters: {
            apiKeyName: string;
            onCode: (authorization: DeviceAuthorization) => void | Promise<void>;
            signal?: AbortSignal;
            timeout?: number;
        }

      Returns Promise<ApiKeyCreated>