Register()

This method is used to authenticate with your application, unless your application has an AuthProcess specified. It is responsible for verifying the supplied user credentials and establishing or renewing a connection. The authentication information will be stored in the metadata object and will be included in all request bodies. All applications must implement the Register method.

If your application has an AuthProcess specified then the Register method will still be called when a user creates a connection, however the connection will have already been authenticated via the configured type - OAuth2, etc... - and the resulting access token will be available in the authorization property of the request. Any additional steps required for connecting a user can occur at this point, such as validating that they have access to specific services and so on. You are not responsible for storing primary authorization information (access tokens, etc...) in the metadata as that has been delegated to the configured auth process in this scenario, but you are free to include any additional information that should be included in future requests relating to the connection.

Syntax

module.exports = async function Register(request) {
// Your code here
}
import { RegisterRequest, RegisterResponse } from "@shipengine/connect-carrier-api";
export const Register = async (request: RegisterRequest): Promise<RegisterResponse> => {
// Your code here
}

Parameters

RegisterRequest

An object containing the authentication information gathered using the connection form you created for your application. It will contain whatever fields you defined in this form. Your method must then use this data to perform authentication with your backend service.

NameTypeNullable?Description
registration_infoobject

An object containing the fields defined in your connecion form.

transaction_idstring

The transaction ID uniquely represents this request. If the request is retried then this transaction ID will be the same. You should only perform the requested action once per given transaction ID.

authorization

authorization object

The authorization information necessary to fulfill this request.

metadataobject

Custom data about this request.

Return Value

RegisterResponse

The Register method returns the result of the carrier's authentication process. This information will be included in the metadata of every subsequent request to your application.

NameTypeRequired?Description
credentialsobject

An object containing basic authentication information for the integration.

credentials.usernamestring

The user's username

credentials.passwordstring

The user's password

metadata

metadata object

This object should contain all of the necessary properties needed to make authenticated requests with the carrier. Every property included here will be persisted by ShipEngine Connect and included on each subsequent request from this user.