Closed gtbmed closed 7 years ago
Sure, you can use this library. It's just the standard OAuth 2.0 flow, so you'd be looking at https://github.com/mulesoft/js-client-oauth2#authorization-code-grant. In that example, you use auth.code.getUri()
to figure out where to send the user, then use auth.code.getToken
when the user is redirected back to your page to get the token.
The auth object would look something like this based on the docs:
var auth = new ClientOAuth2({
clientId: 'your client id here',
clientSecret: 'your client secret here',
accessTokenUri: 'https://api.dexcom.com/v1/oauth2/token',
authorizationUri: 'https://api.dexcom.com/v1/oauth2/login',
redirectUri: 'your callback url here'
})
For anything additional, you may need to provide more information with your question. It's expected to use a server for this OAuth 2.0 flow as there's no way to secure the client secret on a JavaScript web page.
Thanks Blake,
That answers my question. The 304 error I was running into was causing me to question everything. I feel better now that I know I'm using it right. A few more hairs are staying in my head now. After more digging, it seems our routing is going to be the source of all stress as we try to get all of this to work together with react.
If you're interested, we're working on a physician collaboration web app. Once we get it working (Thursday deadline), we'll open it up for others to join in on. https://github.com/Marshall49/StealthChicken-
Are you talking about a HTTP status code? Is that status code coming from your app or somewhere else? A 304 isn't an error, it's actually a "Not Modified" response - it's telling the client (web browser) that nothing has changed since the last time it sent a payload based on the request (e.g. good for browser-side caching, doesn't need to redownload content). The only errors in HTTP is 4xx (client) and 5xx (server). Read more here: https://httpstatuses.com/304. If you're not talking about HTTP, feel free to ignore me 😄
You're right, it was an http 304 response. I think that's what made it so frustrating. It wasn't really an error and I had no idea why it wasn't modifying things. One thing I discovered I was doing wrong was referencing the wrong port (used 3000 where react was instead of 3001 where express was listening). I'm coming to terms with the Software Development Process:
Hey there,
I'm working on my final project for my Web Developer Bootcamp and need to use oauth2 to get pull data from Dexcom's API. They've provided some helpful documentation, but I'm having difficulty understanding how to combine what I need to give them and what your package can do. https://developer.dexcom.com/authentication
Is this the right tool for the job? To get it running before going nuts with features, we want to
Send the user to Dexcom's authorization and authenitcation page, Get the code when dexcom redirects my user Get the code and use it to get the token Call the API with said token and jam the data into mongo.
Is this the right tool for the job? Once I get this, I'd be willing to help make the documentation easier for new people.
Thanks,
New to Web Development