On Graft Cloud, Gmail does not take this path. It connects with one click through Pipedream Connect, whose client is the one you sign in to, and the token stays with Pipedream. See One click on Graft Cloud. This page is for a vendor Pipedream does not cover, and for self-hosted Graft without a Pipedream project of its own.
What the agent proposes
The agent callsrequest_connection with the scheme oauth_authorization_code and, from the vendor’s documentation, the Authorize URL, the Token URL and the Scopes the task needs, as narrow as the task allows. It leaves the client id out, because it cannot know it. The answer carries the handoff link and a redirectUri, and the agent relays both with three sentences: where to create the client, what to name it, and which redirect URI to paste.
Registering the client
1
Create an OAuth client at the vendor
In the vendor’s developer console, create an OAuth client of the web application kind. Name it with “Graft” in it,
Graft (my laptop agent), so you recognise it in the vendor’s list a year from now.2
Paste the redirect URI
The redirect URI is your Graft deployment’s origin plus
/api/oauth/callback. The form shows it with a Copy button, fetched from the server so it is the exact URI the callback answers on. Paste it into the client’s authorized redirect URIs exactly; a character off and the vendor refuses the consent with redirect_uri_mismatch.3
Enter the client on the form
Open the handoff link. The form is pre-filled with the agent’s proposal and asks for two things the agent could not know: the Client id, as a required parameter, and the Client secret, as the one secret. The redirect URI is shown beside them.
4
Connect
Connect stores the client and opens the vendor’s consent page in a popup. Complete the consent there. The form waits and says so; when the vendor sends the browser back, the tokens are stored encrypted, the card settles, and the agent’s waiting call answers
connected. If the browser blocks the popup, the form offers a link to open the consent page yourself. Stop waiting returns the form to Connect if you change your mind; the client id and secret are kept.ctx.fetch as for any other scheme and never see a token.
- A Google Cloud project starts in Testing mode. Add your own Google account under OAuth consent screen → Test users, or the consent page refuses you.
- Create the client under APIs & Services → Credentials → Create credentials → OAuth client ID, type Web application, after enabling the API the scopes belong to (Gmail API for Gmail) under Library.
- Gmail’s read scope is
https://www.googleapis.com/auth/gmail.readonly; the host isgmail.googleapis.com; the endpoints arehttps://accounts.google.com/o/oauth2/v2/authandhttps://oauth2.googleapis.com/token.
When a call fails later
A vendor401 on an OAuth connection usually means the refresh token died: the seven-day expiry above, or you revoked the app at the vendor. Graft has already tried to refresh once and passed the vendor’s own 401 to the tool. The connection card then reads needs re-consent and offers Reconnect, which runs the consent again with the client secret still in place; nothing is typed, and no approval is touched.
The agent can start this for you with request_credential. For an OAuth connection the card asks you to reconnect, not to type anything, unless the connection was revoked in the console, in which case you enter the client secret first and the consent follows.