New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$request.getAccessToken() returns undefined in Google Conversational Actions #915
Comments
Hey @mig82 Could you provide the request JSON? Thanks! |
Hi @aswetlow. What request are you referring to? the one coming back from the account linking scene? If so, this is it:
|
I'm having the same Issue. I tried every getter for the access token without any success. 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 |
Oh yeah, I forgot about that one. Access tokens are located in the request headers now. Unfortunately, the It's implemented for @NLueg provides a great workaround for now. I think we should move the |
@aswetlow actually my workaround doesn't work if the action is hosted on Lambda and I don't really know why 😢 Edit: It's because of the API-Gateway 🤦🏻 The gateway filters the headers so that lambda don't receives the headers. {
"body" : $input.json('$'),
"headers": {
#foreach($param in $input.params().header.keySet())
"$param": "$util.escapeJavaScript($input.params().header.get($param))" #if($foreach.hasNext),#end
#end
}
} And this to the mapping template of the Integration Response: $util.parseJson($input.json('$.body')) Without it the lambda function won't receive the headers. It seems to be a general issue for the api gateway. If you want I could add this part to the documentation as a PR but I don't know if its relevant. |
We have a Conversational Action on Lambda (via API Gateway) and the headers are passed correctly. How did you create the API gateway? From the Lambda configuration page or separately in the API gateway settings? |
@aswetlow well, strange but okay. I created it exactly as described in the documentation as I didn't use the gateway before. But if it is working, then you can ignore it. I don't know what's different in my case. |
Could you log your headers object? Is just the bearer token missing or do you receive an empty object? |
I close this issue due to inactivity. |
I'm submitting a...
Expected Behavior
In Google Conversational Actions...
after the user has successfully gone through the Account Linking Scene and linked their account, and returned to the
ON_SIGN_IN
handler, callingthis.$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.Error log
This is the output of the code above:
Your Environment
The text was updated successfully, but these errors were encountered: