StartDeviceAuthorization
const url = 'https://example.com/hopbox.v1.AuthService/StartDeviceAuthorization';const options = { method: 'POST', headers: { 'Connect-Protocol-Version': '1', 'Connect-Timeout-Ms': '1000', 'Content-Type': 'application/json' }, body: '{"clientName":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/hopbox.v1.AuthService/StartDeviceAuthorization \ --header 'Connect-Protocol-Version: 1' \ --header 'Connect-Timeout-Ms: 1000' \ --header 'Content-Type: application/json' \ --data '{ "clientName": "example" }'StartDeviceAuthorization starts the device flow of the hopbox CLI (RFC 8628). It needs no credential. The CLI shows the user code and the verification URI, then polls with the device code.
Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Define the version of the Connect protocol
Define the version of the Connect protocol
Example
1Define the timeout, in ms
Define the timeout, in ms
Example
1000Request Bodyrequired
Section titled “Request Bodyrequired”StartDeviceAuthorizationRequest describes the client that signs in.
object
Client_name is what the client calls itself, such as “hopbox CLI on ann-laptop”. It has at most 64 characters, and can be empty. The console shows it at the approval.
Example generated
{ "clientName": "example"}Responses
Section titled “Responses”Success
StartDeviceAuthorizationResponse holds the codes of a new device sign-in.
object
Device_code is the secret with which the client polls. It must not be shown.
User_code is the code that the person types in the console, such as WDJB-MJHT.
Verification_uri is the console page where the person approves the code.
Verification_uri_complete is verification_uri with the user code in it.
Expire_time is the end of the device sign-in, 10 minutes after its start.
Interval_seconds is the least time between two polls, 5 seconds.
Example
{ "expireTime": "2023-01-15T01:30:15.01Z"}default
Section titled “default”Error
Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation
object
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
A list of messages that carry the error details. There is no limit on the number of messages.
Contains an arbitrary serialized message along with a @type that describes the type of the serialized message, with an additional debug field for ConnectRPC error details.
object
A URL that acts as a globally unique identifier for the type of the serialized message. For example: type.googleapis.com/google.rpc.ErrorInfo.
The Protobuf message, serialized as bytes and base64-encoded. The specific message type is identified by the type field.
Deserialized error detail payload. The ‘type’ field indicates the schema. This field is for easier debugging and should not be relied upon for application logic.
object
Example
{ "code": "canceled"}