TM1 Rest API – CRUD App – 4th and the Final Chapter
https://tccpro.net/gettcc/web-cookies/

TM1 Rest API – CRUD App – 4th and the Final Chapter

In this chapter we will discuss about login screen and routing the token through the application and deleting the cookie to logout. The login screen looks like below (note: this can be extended to CAM authentication with an input field)

No alt text provided for this image

Once you type in the username and password and click the login button, we can see token generated in the browser application (once we inspect the browser)

No alt text provided for this image

Before we get into what happens in the background when we click the login button. We need to understand how the first page of our application is defaulted to log in screen. This is completed using index.js with routing as below.

No alt text provided for this image

The application’s first screen is “Authentication” and once the authentication is successful the /chores screen will be rendered as “App” (App.js) as this is encapsulated inside cookies provider.

Let’s now check how the authentication is completed against our TM1 login account.

Valid Username and Password

User name and password is converted to base64 format and saved in ‘authToken’ is passed as an argument to loginUser function. This function just tries to do a GET call against the TM1 database. If the get call is successful an active session will be established and then the Token will be set as a cookie and App.js will be rendered as per our routing.

No alt text provided for this image

?The above useEffect checks the token is saved in mr-token and renders the next page. However, it does not check if the token in valid or not (for example: if we authenticate with any username and password the chores page will be rendered at this point). The validity of the token happens in app.js.

No alt text provided for this image

We have three variables’ data, loading and error.?These variables are set in fetch.js as below execution cycle:

1.?????We have asynchronous call to the TM1 server

2.?????setLoading as true and error as null (before anything is retrieved)

3.?????Then call getChores and store it in “data”.

4.?????Catch the error in “error” using setError,

5.?????Set current data (setData (data))

6.?????setLoading to false

7.?????Repeat this process and return the data, loading, error.

8.?????If not errored setChores in app.js and use the token throughout the application.

Invalid Username and Password

The same steps happen till step 8 and If there is error set in “error” variable. Then an invalid credentials alert is popped up.?

No alt text provided for this image

Logout

The logout button is on the right-side top corner. When clicked it deletes the token and closes the TM1 session. Once token is deleted the second useEffect in App.js defaults to the login screen.?

No alt text provided for this image

This completes the series of TM1 (PA) rest API CRUD operation. This web application can be extended to any usecase within TM1 (PA) For example: Source code version control with GITHub integration. Furthermore, this application can be further optimised.

Links

1stChapter

2nd Chapter

3rd Chapter



要查看或添加评论,请登录

Akram Ali的更多文章

  • 3 Simple Steps to run LLMs on your Laptop

    3 Simple Steps to run LLMs on your Laptop

    Install Ollama: Visit ollama.com and download the installer for your OS (Mac or Windows).

  • From Engineer to Associate Accountant: A Journey of Transformation

    From Engineer to Associate Accountant: A Journey of Transformation

    For years, I worked as a consultant, delivering enterprise performance management solutions to clients, primarily…

    24 条评论
  • Generative AI: Lack of Information Architecture increases misinformation risks

    Generative AI: Lack of Information Architecture increases misinformation risks

    Imagine AI as a powerful engine. It can take you anywhere, but without a proper roadmap (Information Architecture)…

    2 条评论
  • Generative AI with Planning Analytics and WatsonX

    Generative AI with Planning Analytics and WatsonX

    Generative AI itself is a type of artificial intelligence that can create new content like text, images, audio and even…

    1 条评论
  • ESG - Sustainability - TM1/PA

    ESG - Sustainability - TM1/PA

    TM1/PA – ESG – Sustainability IBM accelerator catalog is a great place to look at the knowledge base on IBM technology.…

    1 条评论
  • PA SaaS in AWS

    PA SaaS in AWS

    Planning Analytics as a service in AWS has been one of the most awaited announcements for Enterprise Performance…

  • Finance Transformation - On Premises vs Cloud

    Finance Transformation - On Premises vs Cloud

    As part of the Finance Transformation journey many organisations across the globe are assessing/assessed their software…

  • TM1 Rest API – CRUD App – 3rd Chapter

    TM1 Rest API – CRUD App – 3rd Chapter

    In this chapter we are going to discuss on update and delete operation of rest API. Among PUT/POST/Patch, based on the…

  • TM1 Rest API – CRUD App – 2nd Chapter

    TM1 Rest API – CRUD App – 2nd Chapter

    This article is a continuation of the 1st chapter and it will discuss on POST operation of TM1 Rest API. Also, this…

    1 条评论
  • TM1 Rest API – CRUD App – 1st Chapter

    TM1 Rest API – CRUD App – 1st Chapter

    As we all know Representational state transfer (REST) Application programming interface (API) can perform Create Read…

    3 条评论

社区洞察

其他会员也浏览了