OAuth Redirect URI with dynamic parameters

I need dynamic parameters to be sent in the redirection that is made after the implicit grant token concession. Being dynamic, I can not configure the redirect URI that the OAuth requests.
The redirection web service that I created is a servlet in Java + HTML / JavaScript and it must be in this language.
In JavaScript I retrieve the hash of the token but I can not define the redirect servlet there to have access to previously defined global data in a previous servlet. I think that JavaScript does not allow to define the servlet, NodeJS does, but I can not use this language.

I tried:

  1. Oauth configuration: ...localhost:8080/Services/services/script/token

Request: .../oauth/authorize?client_id=XXXXXXXXXXXXXX&response_type=token&redirect_uri=http://localhost:8080/Services/services/script/token?conversationId=1234

Redirection response: https://login.mypurecloud.ie/#/error?errorKey=invalidRedirectUrl

  1. If I change ¿for ? , the token is generated and it redirects but we don't get the parameter.
    Oauth configuration: ...localhost:8080/Services/services/script/token

Request: .../oauth/authorize?client_id=XXXXXXXXXXXX&response_type=token&redirect_uri=http://localhost:8080/Services/services/script/token?conversationId=1234

Redirection response: ...localhost:8080/Services/services/script/token#access_token=r9NVc4EmhoKO2uLAT4qCZa0UJZmtwlqT9F8OVSOF2OOViiqz9oPdvqDlIma09wyU01k2yHujkW6xJ0jm-diwhg&expires_in=86399&token_type=bearer

  1. If I change Oauth configuration to send the parameter, I must send it in a static way, what it doesn't suit my service, because the parameter will change with each interaction.

Thanks in advance.

You may use the state query string parameter when redirecting to login.mypurecloud.com to initiate the oauth flow. The state parameter will be returned to you in the query string or fragment, depending on the grant type, when the user is redirected back to your app.

Thank you Tim, in order to be sure, could you confirm which programming language you are referring to, with state suggestion? Do you have any example at your hand? Thank you so much.

Query strings are part of the URI, not a programming language.

https://login.mypurecloud.com/oauth/authorize
?client_id={my-client-id}
&response_type=token
&redirect_uri={http://example.com/oauth/callback}
&state={someuriencodeddata}
1 Like

Thanks for your help, Tim, it worked perfectly.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.