question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$request.getAccessToken() returns undefined in Google Conversational Actions

See original GitHub issue

I’m submitting a…

  • Bug report
  • Feature request
  • Documentation issue or request
  • Other… Please describe:

Expected Behavior

In Google Conversational Actions…

const { GoogleAssistant } = require('jovo-platform-googleassistantconv')

after the user has successfully gone through the Account Linking Scene and linked their account, and returned to the ON_SIGN_IN handler, calling this.$request.getAccessToken() should return the access token.

Current Behavior

The function GoogleAction.$request.getAccessToken() is defined, yet it never returns the token, despite the account being linked.

console.log(`this.constructor: '${this.constructor.name}'`)
console.log(`typeof this.$request.getAccessToken: '${typeof this.$request.getAccessToken}'`)
console.log(`this.$request.getAccessToken(): '${this.$request.getAccessToken()}'`)

Error log

This is the output of the code above:

this.constructor: 'GoogleAction'
typeof this.$request.getAccessToken: 'function'
this.$request.getAccessToken(): 'undefined'

Your Environment

$ jovo -v

Jovo CLI Version: 3.2.1

Jovo packages of current project:
  jovo-core: 3.3.1
  jovo-db-filedb: 3.3.1
  jovo-framework: 3.3.1
  jovo-platform-alexa: 3.3.1
  jovo-platform-googleassistantconv: 3.3.2
  jovo-plugin-debugger: 3.3.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
NLuegcommented, Apr 1, 2021

I’m having the same Issue. I tried every getter for the access token without any success. I managed to get the token with the following code:

export function getAccessToken(jovo: Jovo): string | undefined {
  if (jovo.$request && jovo.isAlexaSkill()) {
    return jovo.$request.getAccessToken();
  }

  // TODO: Temporary hack to receive the access-token
  if (jovo.isGoogleAction()) {
    const headers = jovo.$googleAction.$user.conversationalAction.$host.headers;
    const accessTokenWithBearer = headers['Authorization'] || headers['authorization'];
    return accessTokenWithBearer?.replace("Bearer ", "");
  }

  return undefined;
}

But I think that the problem is inside the ConversationalActionRequest. It seems to be expected, that the access token is inside the user but this is not the case for me too.

0reactions
aswetlowcommented, Jan 5, 2022

I close this issue due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

idToken undefined in result.authentication (authSession with ...
Summary When getting a response back from promptAsync using AuthSession with Google, I get an authentication value with an undefined id_token.
Read more >
AppRequest | Dialogflow and legacy Actions SDK
AppRequest is a request sent by the Google Assistant to a fulfillment in order to interact with an Action. The API version is...
Read more >
Action on google missing access token - Stack Overflow
According to doc the access token should be in user object but it's not there in my case. Below is request { "requestJson":...
Read more >
Google Auth Library: Node.js Client
This is Google's officially supported node.js client library for using OAuth 2.0 authorization and authentication with Google APIs.
Read more >
Obtaining Access Tokens using 3-legged OAuth flow
To perform actions on behalf of another user, you'll need to obtain their access tokens. Access tokens specify the Twitter account the request...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found