I am currently using Ionic 2 to create this application
So in order to properly authenticate a user with my application, my company requires them to sign in with their credentials. To acheive this, I am to utilize 0authv2 and Ionic 2 (preferably typescript). The instructions provided are as follows:
After a user signs in, they are redirected to the redirect uri, with an authorization code attached in the URL: The redirect would look something like this (assuming the application is “demoapp.com”) demoapp.com
At this point, the application will request a token from their server, and pass it to the authorization endpoint. The POST request that they provided me as an example is as follows:
POST https://INTERNAL_URL_PROVIDED/oauth/ls/connect/token
client_id <clientid>
client_secret <client secret>
code CODE IN RESPONSE
grant_type authorization_code
redirect_uri INTERNAL_URL_PROVIDED
{code=CODE IN RESPONSE&client_id=client.id&client_secret=client.secret&redirect_uri=https%3A%2F%2FINTERNAL_URL_PROVIDED%2Fcallback&grant_type=authorization_code}
If the authorization is valid, the authorization server will send a response containing the access token (and optionally, a refresh token) to the application. The entire will look something like this:
{
"access_token":"INTERNAL_ACCESS_TOKEN","expires_in":EXPIRATION_TIME,"token_type":"Bearer","refresh_token":"INTERNAL_REFRESH_TOKEN"}
My question is, how do I go about actually handling this, as well as handling the response that I get to store the token? I would extract the code from the URL, and then post it back to their server? I would assume that I would store it in local storage, and then check to see if it is valid when the user opens the application (these expire every so often). Do I need to utilize a GET request first to properly handle and preface this situation? Any help would be so appreciated.