Morry | 2022-04-20 06:10:32 UTC | #1
Hello
I used loginImplicitGrant, and when we login the Genesys, it is ok, we can get the information.
But when we don’t login Genesys, seems it will redirect to Genesys Cloud login page. We don’t want to open Genesys login page, just keep in our system page without any alert is fine.
Can you help?
Thanks
Jerome.Saint-Marc | 2022-04-20 07:57:55 UTC | #2
Hello,
This is the expected behaviour with OAuth Implicit Grant flow.
loginImplicitGrant triggers an Authentication/Authorization flow, to get an access token from Genesys Cloud. The access token is related to the user's account (so that you can invoke Platform API from your code using the user's identity/credentials/authorization/permissions).
If you are already connected/logged to Genesys Cloud in your web browser, and if you open a web page in a different tab that makes use of loginImplicitGrant, it will also trigger the Authentication/Authorization flow. But as you are already authenticated, the authorization flow will be transparent to the user (a web browser is able to share cookies between tabs) and your code will get an authorization/access token.
If you are not connected/logged, you will be redirected to the login page so that the user can enter his username and password and get authenticated/
Regards,
Morry | 2022-04-21 05:27:06 UTC | #3
Hi Jerome,
Thank you very much for the answer. seems when I used loginImplicitGrant without logged, I will be redirected to the login page.
Can I used other Genesys API to check logged or not in browser before used loginImplicitGrant. May be it is not ok.
Thanks
Jerome.Saint-Marc | 2022-04-21 12:22:39 UTC | #4
Hello,
seems when I used loginImplicitGrant without logged, I will be redirected to the login page.
Yes, that is correct.
Can I used other Genesys API to check logged or not in browser before used loginImplicitGrant. May be it is not ok.
No, there is unfortunately no such method/API.
Regards,
tim.smith | 2022-04-21 13:47:26 UTC | #5
Morry, post:3, topic:14377
Can I used other Genesys API to check logged or not in browser before used loginImplicitGrant. May be it is not ok.
Your app should know whether or not it has an auth token. You can check this in the SDK via apiClient.authData.accessToken. That will be your first indication if the user is logged in. If you do have a token, you can validate it by making any API request. GET /api/v2/users/me is a common one that will give you info about the user or a 401 if the token isn't valid.
Morry | 2022-04-25 06:10:04 UTC | #6
Hi Tim
Thank you very much for the answer.
I checked, If I am logged Genesys, I can get accessToken. but when I am not logged, use loginImplicitGrant will redirect to login page, I can’t get if the token isn't valid. I think maybe I'm misunderstanding something.
client.loginImplicitGrant(clientId, redirectUri) .then(() => { console.log(client.authData.accessToken); }) .catch(err => console.error(err));
Thanks
Morry | 2022-04-25 06:15:17 UTC | #8
Jerome.Saint-Marc, post:4, topic:14377, full:true
Hello,
seems when I used loginImplicitGrant without logged, I will be redirected to the login page.
Yes, that is correct.
Can I used other Genesys API to check logged or not in browser before used loginImplicitGrant. May be it is not ok.
No, there is unfortunately no such method/API.
Regards,
Hello Jerome,
Thank you very much.
system | 2022-05-26 06:15:28 UTC | #9
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 14377