Skip to content
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

Unable to get AVS Token #57

Closed
seattlecajun opened this issue Jan 8, 2018 · 31 comments
Closed

Unable to get AVS Token #57

seattlecajun opened this issue Jan 8, 2018 · 31 comments

Comments

@seattlecajun
Copy link

Hi there, I've setup an account and created an 'app' for the AVS on the Amazon developer's site but I'm not able to complete the setup by getting the access token to generate the config.

I'm able to get to the Amazon login page and see the prompt about 'when you click okay, we'll provide Magic Mirror connectivity to Amazon Alexa" ('Magic Mirror' is the name of my AVS 'app').

Unfortunately, when I hit okay, I'm directed to an Amazon Error page stating "we're sorry! an error has occurred when we tried to process your request, etc".

I've tried the method using the auth_code.sh and auth_code2.sh bash scripts but ultimately received the same 'we're sorry' error message from Amazon.

Any idea where I could have gone wrong?

@dolanmiu
Copy link
Owner

dolanmiu commented Jan 8, 2018

When it says:

"we're sorry! an error has occurred when we tried to process your request, etc"

Can you expand that message?

Then paste it here

@seattlecajun
Copy link
Author

Hi @dolanmiu, unfortunately, no. It's not an in-depth error message that offers any actual details - just a generic page with that wording.

amazon error

@dolanmiu
Copy link
Owner

dolanmiu commented Jan 8, 2018

Normally when I get that error, its because the URLs weren't set properly on Amazon's side

@vivekpk007
Copy link

Same error here, any fixes ??

@nitrogen73
Copy link

The same issue im also facing here

@devmil
Copy link

devmil commented Jan 13, 2018

I have exactly the same problem.

@dolanmiu
Copy link
Owner

Getting the refresh token is out of scope of this MMM module

I will re-think of a way to make this process easier

@devmil
Copy link

devmil commented Jan 13, 2018

Can you hint at any other method of getting the token?

@dolanmiu
Copy link
Owner

dolanmiu commented Jan 13, 2018

The methods are on the README, personally I use the tool I built (mentioned in the README):

https://magic-mirror-avs.github.io/Alexa-Web-Helper/

But it seems not everyone has luck with it

Are they following instructions properly? Is the country they are in not supported? I have no idea at this point

@devmil
Copy link

devmil commented Jan 13, 2018

I did the method 2 using ARC (https://github.com/dolanmiu/MMM-awesome-alexa/wiki/How-to-get-AVS-Token-2) and that one was working. No idea what went wrong with the Alexa-Web-Helper

@dolanmiu
Copy link
Owner

So you are all set? Got the refresh token?

@devmil
Copy link

devmil commented Jan 13, 2018

Yes, I have a refresh token now. Got it through the second alternative (not using the helper from Awesome Alexa)

@DaDonkDon
Copy link

Hello,

just readed all issues to the topic to get the refresh token.

  1. Tried https://magic-mirror-avs.github.io/Alexa-Web-Helper/, but it seems it doesn´t work for me
  2. Tried the scripts:
CLIENT_ID="amzn1.application-oa2..."
DEVICE_TYPE_ID="pi..."
DEVICE_SERIAL_NUMBER=123
REDIRECT_URI="https://localhost:9745/authresponse"
RESPONSE_TYPE="code"
SCOPE="alexa:all"
SCOPE_DATA="{\"alexa:all\": {\"productID\": \"$DEVICE_TYPE_ID\", \"productInstanceAttributes\": {\"deviceSerialNumber\": \"${DEVICE_SERIAL_NUMBER}\"}}}"

function urlencode() {
  perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"'
}

AUTH_URL="https://www.amazon.com/ap/oa?client_id=${CLIENT_ID}&scope=$(echo $SCOPE | urlencode)&scope_data=$(echo $SCOPE_DATA | urlencode)&response_type=${RESPONSE_TYPE}&redirect_uri=$(echo $REDIRECT_URI | urlencode)"
xdg-open ${AUTH_URL}

Also the url is filled @amazon:
image

First errors:

pi@pisander:~/MagicMirror/modules/MMM-awesome-alexa/help/bash-scripts $ chmod aug+x auth_code.sh
pi@pisander:~/MagicMirror/modules/MMM-awesome-alexa/help/bash-scripts $ ./auth_code.sh
Can't locate URI/Escape.pm in @INC (you may need to install the URI::Escape module) (@INC contains: /etc/perl /usr/local/lib/arm-linux-gnueabihf/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/arm-linux-gnueabihf/perl5/5.24 /usr/share/perl5 /usr/lib/arm-linux-gnueabihf/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/arm-linux-gnueabihf/perl-base).
BEGIN failed--compilation aborted.
Can't locate URI/Escape.pm in @INC (you may need to install the URI::Escape module) (@INC contains: /etc/perl /usr/local/lib/arm-linux-gnueabihf/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/arm-linux-gnueabihf/perl5/5.24 /usr/share/perl5 /usr/lib/arm-linux-gnueabihf/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/arm-linux-gnueabihf/perl-base).
BEGIN failed--compilation aborted.
Can't locate URI/Escape.pm in @INC (you may need to install the URI::Escape module) (@INC contains: /etc/perl /usr/local/lib/arm-linux-gnueabihf/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/arm-linux-gnueabihf/perl5/5.24 /usr/share/perl5 /usr/lib/arm-linux-gnueabihf/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/arm-linux-gnueabihf/perl-base).
BEGIN failed--compilation aborted.
[7487:7487:0126/172856.140633:ERROR:sandbox_linux.cc(344)] InitializeSandbox() called with multiple threads in process gpu-process.
[1:12:0126/172856.217032:ERROR:adm_helpers.cc(62)] Failed to query stereo recording.

But Chromium opens and shows this:
image

Can anybody help me to get a solution? Thanks!

@Albiorix2016
Copy link

Im having the same issue. I've tried to use the helper site from the pi and i've tried both the other methods as well as the scripts. with the website methods i get the generic amazon error message

We're sorry!An error occurred when we tried to process your request. Rest assured, we're already working on the problem and expect to resolve it shortly.

with the script im getting

./auth_code.sh: line 11: syntax error near unexpected token ('
./auth_code.sh: line 11: perl -MURI::Escape -ne 'chomp;print uri_escape($),"\n"''

i really am not sure where to go from here

@E3V3A
Copy link

E3V3A commented Mar 15, 2018

What is this DEVICE_SERIAL_NUMBER=123 ??
I didn't see any serial number anywhere in the AWS Dashboard...

@henrikra
Copy link
Collaborator

@E3V3A Check my node script PR and check its code. It explains it

@E3V3A
Copy link

E3V3A commented Mar 16, 2018

@henrikra Sorry, but your PR doesn't say anything about that. Or it may be that I can't find the right PR, since I can only see one.

@DaDonkDon You are missing the PERL module needed to run the script. You should ask the repo owners to document how to install that. (Hint: mpan,cpan,cpanp )

@henrikra
Copy link
Collaborator

@E3V3A
Copy link

E3V3A commented Mar 16, 2018

@henrikra You could just have said so, no? (Would have saved both of us time and effort looking around.)

@justjim1220
Copy link

Could someone tell me what the Device ID is?
And, where to find it?
screenshot 3

I've tried everything and not getting anywhere!

Also, the Allowed Return URL: https://sakirtemel.github.io/MMM-alexa/ keeps giving me this:
screenshot 1
whenever I try to add it to my AVS Security Profile.

I have made all the changes per @henrikra made, but I can't get any further getting the codes I need to connect to AVS because all three of the processes listed to obtain the refesh tokens either ask for a Device ID and/or refer to the URL that gives error at Amazon.

What am I doing wrong or what step(s) am I skipping or missing or possibly overlooking???

@E3V3A
Copy link

E3V3A commented Mar 17, 2018

I agree with @justjim1220 and have the same exact problem.

I have tried all 3 of the options (and countless variations) available in the (rather confusing and unclear installation instructions). I have even tried using other tools. Still I am not able to get the code needed to get the refresh_token. Pasting the result URL in my browser ask me to login and then I get the same error as @seattlecajun s first picture.

The installation instructions are not very clear since they are all using different URLs.

I suggest the maintainers and developers of this repo to please have a look at your own instructions and follow them from scratch, and come back and help us walk through this and explain how to do this right. ❤️

  • Is this an URL, return URI or origin problem?
  • Updated AWS service problem?
  • lacking doc problem?

I'm just about to give up on this project...

@E3V3A
Copy link

E3V3A commented Mar 19, 2018

Ok, I've rewritten the Bash script and found out that the reason it doesn't work for so many people is the following. You should read the Amazon documents more carefully and fix the installation docs.

https://developer.amazon.com/docs/alexa-voice-service/authorize-companion-site.html#lwa
https://developer.amazon.com/docs/login-with-amazon/authorization-code-grant.html#Access%20Token%20Request

  1. The first script is missing the state request parameter:

state: An opaque value used by your client to maintain state between the request and the response.
The authorization service will include this value when redirecting the user back to the client. It is also
used to prevent cross-site request forgery. For more information, see Cross-site Request Forgery.

When they say opaque, they mean a random 256 bit value, or simply 32 random hex values, but can probably be less.

  1. The request JSON is badly formed with spaces. There should be no spaces in the request string.

  2. The code token generated:

    • can only be used once in the next refresh_token script! (If the wget request fails, you need a new code.)
    • probably has a timeout as well
  3. The refresh and access tokens only lasts for 1 hour (3600 seconds)

The access token is valid for one hour. When the access token expires or is about to expire you can exchange the refresh token for new access and refresh tokens.

Thus, I would guess, in order to keep this running, we need both tokens?

  1. The ProductID is NOT the Amazon ID, it is the ID you gave to your device or mobile app.

@dolanmiu @henrikra
I hope this helps and that someone can do some fixes.

PS. Why don't you merge the node script authentication so that it is more easily available/fixable.

@henrikra
Copy link
Collaborator

@dolanmiu Can you do final testing to the node script PR so we can merge it? :D @E3V3A Is the pr good for you too?

@E3V3A
Copy link

E3V3A commented Mar 19, 2018

@henrikra

Is the pr good for you too?

TBH, IDK.
I tried it, and it didn't work, so I went back to use the bash scripts to try to figure out what was wrong. Then I discovered I'd tried to use the Amazon ID instead of ProductID, but by that time I already made a few modifications and improvements (as mentioned above) to the bash scripts. Which then worked. In conclusion, I don't know if they would work for me.

However, eventually we should try to Node all the scripts, so that it can be automated into the app itself, given that we already give the config info there. It's a bit annoying to have to enter almost the same data in at least 3 different places. I still think you should merge those scripts into the main, but don't remove the bash, yet.

@henrikra
Copy link
Collaborator

@E3V3A But why did you try to use Amazon ID when the node script asks for ProductID?

@justjim1220
Copy link

Ok, I guess I'm a bit confused at this point...
from @E3V3A 's last post regarding LWS... I'm getting that for anyone to use this module, it has to be a Web App or a device in which I have to set up a User Login.

What I want is for my Family MagicMirror, one used by several people in my family, And I don't want everyone to have to have their own Aamzon Login.

I just want to be able to use Alexa within the mirror as an Interactive Personal Assistant. One that will have Facial recognition, or Voice Recognition, or Both being able to know which family member is currently wanting to use the Mirror.

I don't have a website to attach to Alexa requiring a User Login. All I need is for Alexa to interact with my family in the same manner as Echo.

Basically, I would like make my mirror to interact exactly like an Echo device, but not have to purchase an Echo device.

So, am I in the right place within these forums?
Can anyone point me in the right direction?
Can anyone give me any ideas of how to incorporate this the way I am wanting it to work?

@henrikra
Copy link
Collaborator

@E3V3A
Copy link

E3V3A commented Mar 20, 2018

@justjim1220

I would like make my mirror to interact exactly like an Echo device

That's what we all want. But it take some time getting used to the various jargon, interfaces and developer sites (Amazon).

It works pretty close to Echo, but after you create the device and have it connected to your MM, then you need to login to the Alexa setting site. This is different from the developer site. There you can train the voice, setup new skills and location etc.

https://alexa.amazon.com/spa/index.html#cards

@iamshadmirza
Copy link

I'm trying to generate refresh token. When I am copy pasting the link to the browser to authorize Alexa , I'm getting a blank webpage with message:
{"error":"MissingParams","message":"The following parameters were missing or empty strings: state"}
I tried Alexa helper module for token generation, still getting same error.

@onkararj
Copy link

im getting

"This site can’t be reached

localhost refused to connect.

this error
help plz

@dolanmiu
Copy link
Owner

This error is intended

All the info you need is in the address bar

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

No branches or pull requests