Could someone help me to figure out the endpoints for Authorization Code Flow. What I want is following endpoints:
Authorization URL Client ID Redirect URL Authorization Grant Type: Authorization Code Grant Access Token URI Client Secret Client Authentication Scheme
What I was trying to do is create a Alexa Smart Home Skill work which works with Particle Photon. For this Amazon Alexa Skill Kit needs OAuth2 server which supports Authorization Code Flow. The project is complete and is working fine with Login with Amazon. I am able to control lights using Alexa Smart Home Skill Kit. What I was looking for is to use Particle login and retrieve access token and device id. Since Particle IFTTT channel supports OAuth2, it should work for Amazon also.
Probably @harrisonhjones or othes could help me to figure it out.
I have indeed already done this before. Let me dredge up my old settingsā¦ ok, must be archived. Itāll have to wait till tomorrow. Letās see if I can help the old fashioned way.
Just wanted to add for anyone else who pulls this up - things have changed a little bit on Alexaās side since this post was made and I wanted to make sure any common errors are covered:
Client type type=app
Provide the redirect_uri=https://pitangui.amazon.com/api/skill/link/XXX
Scope in the amazon UI - (Can be anything - profile works)
Make sure you create your Lambda endpoint (ARN) and save that at the same time - otherwise you get a very cryptic error.
@harrisonhjones, Iām getting a 400 error in my Alexa app when I try to Enable the skill I built. Iām still a bit confused about how to configure the Alexa skill. Iām using my Particle IDE username for the Client ID. Is that correct? For the Client Secret, Iām using the Access Token for the IDE. Again, is that correct?
Iām sure this is all obvious to you folks, but Iāve wasted lots of time trying to get my Alexa skill to work. The Particle documentation on Oauth is just not detailed enough for me.
You need to generate OAuth client Ids and secrets to get this to work. Iām not sure why that information is missing from the docs. You can find it here. Let me know if you have any trouble
Note: When you create your client Id and secret make sure you use the web type
Iām also trying to build an Alexa skill that interfaces with a userās own Particle account, and Iām a bit stumped on one aspect of the instructions provided here and on the web site. Ultimately, the goal is to allow the user to get an access token to his/her Particle account, so that my Alexa skill can inspect their devices.
The part Iām confused about is why I am creating an oauth client using my access token for this whole process and loading that up into my Alexa skill. Does that mean the access token they create is somehow tied to my Particle account? I.e. will they have access to my devices? I donāt understand the relationship between my oauth client (associate with my account) and the customerās own access token they are generating for their account.
Or can my oauth client request an access token for any other Particle account so long as it has their username and password?
@harrisonhjones Iām also attempting to integrate Alexa and am having trouble with the OAuth authentication. Your previous posts are very helpful, and I worked through the ā400ā error problem by changing my client to web type and adding the redirect url.
Now when I attempt to enable my skill in the Alexa web page Iām passed through to the Particle login page and get asked by Particle to authorize the requested access. I click āOKā and am taken to an Alexa page that indicates the linking was unsuccessful.
Iāve turned on browser logging but canāt see what is going wrong. Items of note:
Unfortunately I donāt frequent these forums anymore (my day job is consuming my entire life) but Iām happy to help when I can. From your list of urls my guess is the last step, where Amazon requests an OAuth token and refresh token, is failing. This usually occurs because of a incorrect access token URI. What URI do you have set in your Alexa app?
@developer what an interesting error. From the response that looks like a Particle response and not an Amazon response. Can you provide screenshots of the entire flow till the error? Are you viewing the page in a webview?
Iāve been trying to gather more information but still no luck even after many different attempts at creating lambda functions and skills. The access token URI I set is from your doc, https://api.particle.io/oauth/token
As far as I can see Particle is correctly generating a code and returning it to Amazonās pitangui server, along with the āstateā variable. Amazon must then be requesting a token from the URI I supply as I can see one has been created with my client_id in Particle if I list v1/access_tokens. I get a new one every time I attempt to link the accounts.
Iāve attempted to use the returned ācodeā in a POST to see if I can find any error detail. I posted the following:
{āerrorā:āinvalid_clientā,āerror_descriptionā:āThe grant type is unauthorised for this client_idā}
I suspect that the code canāt be used again once a token is issued, but perhaps this error is meaningful? Just to confirm, I created the Particle client as type web with the same redirect URI as appears in the requests:
{ānameā:āAlexaā,ātypeā:āwebā,āredirect_uriā:āhttps://pitangui.amazon.com/api/skill/link/XXXX",āidā:"alexa-1185ā}]}
Quick update: turns out changing the Alexa skill to V2 (legacy) instead of V3 (preferred) allow the account linking to proceed. There must be some additional required function that is missing from my sample code. Unfortunate the error was so cryptic - the oauth was working fine the whole time.
Iāll continue to work on a V3 version and post a sample if I ever get it to work.
Iāve been using Particle.io oauth with both an Alexa smart home skill as well as a custom skill. The custom skill is posted on Github.
I recently posted a step-by-step article on my website about creating an Alexa custom skill using particle.io oauth to publish events to your devices. Itās very detailed, and a long read, but hopefully it will help folks figure out which steps theyāre not doing, or doing incorrectly.
Unfortunately the Amazon stuff changes, and it gets pretty hard to figure out if youāre working with outdated information. I know the steps I list work as of today 11/26/17.