question

newuser-9f3bb8c6-6955-49dd-81f7-80ce77e99837 avatar image

How do you request User Contact information?

For now, I am just trying to get the User's full name. I am using my own account and have made sure that I have all the permissions set correctly. When I make the request to amazon though I get back a 401 error with this message:

"Could not find resource for URI: v2/accounts/~current/settings/Profile.name" (where ~current is the userId)

This is the domain I am hitting: https://api.amazonalexa.com/

And I am adding the Header: "Authorization: <TheapiAccessTokenValue>" to the request

I have also tried the Header: "Authorization: Bearer <TheapiAccessTokenValue>" as the Documentation suggests but get a 404 error when I do it that way.

I also made sure that I am making a Get request.

I think there is something wrong with the userId. I am getting it from the JSON at Context.System.User.userId. Is the userId supposed to be formatted a certain way or am I missing something else?

alexa skills kitdocumentationcustomer contact permissions
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jenn@amazon avatar image
Jenn@amazon answered

The GET is to the URL:

https://api.amazonalexa.comv2/accounts/~current/settings/Profile.name

The note about ~current means it'll pull the info for the current user associated with the Access Token. Not to replace the ~current value with the userId.

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jenn@amazon avatar image
Jenn@amazon answered

The user ID in context.system.user.userId is unique to Alexa.

For the calls to LWA, you'll need the accessToken -> context.system.user.accessToken

1 comment
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sorry did not realize that when I hit add reply it would create a new post. Please see the new "Answer".

0 Likes 0 ·
newuser-9f3bb8c6-6955-49dd-81f7-80ce77e99837 avatar image
newuser-9f3bb8c6-6955-49dd-81f7-80ce77e99837 answered

I did not think this was a call to LWA. This is what your documentation says: "The Customer Profile API uses information from the active default Alexa profile, which may or may not represent who is speaking to Alexa."

Also there is no Access Token in the JSON Alexa is sending to my API. Here is a sample JSON of the call she would make:

{
	"version": "1.0",
	"session": {
		"new": false,
		"sessionId": "amzn1.echo-api.session.**************",
		"application": {
			"applicationId": "amzn1.ask.skill.**********"
		},
		"user": {
			"userId": "amzn1.ask.account.*************",
			"permissions": {
				"consentToken": "********"
			}
		}
	},
	"context": {
		"System": {
			"application": {
				"applicationId": "amzn1.ask.skill.******"
			},
			"user": {
				"userId": "amzn1.ask.account.*****",
				"permissions": {
					"consentToken": "***** (This is the same as the apiAccessToken)"
				}
			},
			"device": {
				"deviceId": "amzn1.ask.device.******",
				"supportedInterfaces": {}
			},
			"apiEndpoint": "https://api.amazonalexa.com",
			"apiAccessToken": ""
		}
	},
	"request": {
		"type": "IntentRequest",
		"requestId": "",
		"timestamp": "2018-08-01T20:32:19Z",
		"locale": "en-US",
		"intent": {
			"name": "InfoRequest",
			"confirmationStatus": "NONE"
		}
	}
}

3 comments
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

UPDATE: I can successfully get the CountryandPostalCode using the same code just with deviceId substituted for userId. However, I cannot get a fullname or email

0 Likes 0 ·

Ah, gotcha. Sorry, I was a bit confused. Let me look into this and get back to you shortly.

0 Likes 0 ·
darianbjohnson avatar image
darianbjohnson answered

Man, this really needs to be cleared up in the documentation. I kept getting an invalid URI mistake because I was replacing "~current" with the userId

1 comment
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Yep, I asked the team to update the docs and remove the reference to the userId.

0 Likes 0 ·
customercontact.png (150.6 KiB)