Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

token.refresh failing finally() not defined #170

Open
sdetweil opened this issue Mar 14, 2021 · 1 comment
Open

token.refresh failing finally() not defined #170

sdetweil opened this issue Mar 14, 2021 · 1 comment

Comments

@sdetweil
Copy link

I am trying to upgrade the dependencies on a node/browser app to current levels to get rig of a grpc problem.

one, google-assistant, uses a module that uses popsicle

i call a client-oauth method to refresh my oauth2 token and now get an error that finally is not defined..

if i change the finally()'s to .then() (workaround)
i now get a : socket.ref is not a function
both from popsicle-transport-http

running node 14.15.3
in electron 11.3.0

i read in my old refresh token and then update it

				GA_Auth = new ClientOAuth2({
					clientId: keyinfo.installed.client_id,
					clientSecret: keyinfo.installed.client_secret,
					accessTokenUri: keyinfo.installed.token_uri,
					authorizationUri: keyinfo.installed.auth_uri,
					redirectUri: "http://localhost:5000/assistant_auth", 
					scopes: ["https://www.googleapis.com/auth/assistant-sdk-prototype"],
				});
...
					let tokeninfo = JSON.parse(
						fs.readFileSync(_gp.resolve(_ourpath, "token.json"))
					);
					var token = GA_Auth.createToken(
						tokeninfo.access_token,
						tokeninfo.refresh_token ? tokeninfo.refresh_token : null
					);

					// Set the token TTL.
					token.expiresIn(60 * 24 * 60); //seconds
					console.log("assistant refreshing access token on startup");
					// Refresh the users credentials and save the new access token and info.
					token
						.refresh()
						.then((user) => {
							console.log("assistant saving tokens on startup");
							saveTokens(user);
							AssistantInit(gaconfig, geoposition);
						})
						.catch((error) => {
							console.log("error on startup refresh ="+error);   //< code goes here on finally/socket.ref
						});
@sdetweil
Copy link
Author

also socket once() not found

 line 576               // Existing socket may already have negotiated ALPN protocol.
                if (socket.alpnProtocol != null)
                    return onConnect();
                socket.once("secureConnect", onConnect);
                socket.once("error", onError);
                socket.once("close", onClose);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant