oAuth 2.0 - Authorization Grant type - Auth pages swapped - Code invalid "Not logged in, or expired"

jeff00seattle
Kilo Guru

I wish to perform "oAuth 2.0 - Authorization Grant type",  and I am following the steps laid out in KB0725643:

How to generate bearer token for oAuth 2.0 - Authorization Grant type

 

My problem is with the section "Generate Authorization Code".

The expected form order for authentication is "Authenticate" then "Allow," which would generate an "authorized code".

 

My attempt's form order is "Allow" then "Authenticate," which generates an "unauthorized code." Returning an error message: "You are not logged in, or your session has expired. Redirecting to the login page."

 

Application Registry OAuth

OAuth was created following the steps of KB0725643

ACT-ServiceNow-App-Global-OAuth-Application-Registries-ServiceNow.png 

 

 

Authentication Request

https://[DEV INSTANCE].service-now.com/oauth_auth.do?response_type=code&client_id=[CLIENT ID]&redirect_uri=https%3a%2f%2f[DEV INSTANCE].service-now.com%2flogin.do&state=12345

 

Redirected to "Allow" Page instead of expected "Authenticate" Page

 

KB0725643 expects initial redirection to oauth login page: /oauth_login.do.

Yet, instead redirected to oauth allow page: /oauth_auth_check.do.

 

https://[DEV INSTANCE].service-now.com/oauth_auth_check.do?sysparm_oauthapp_id=***  

 

ServiceNow_Allow.png

Redirected to Authenticate Page with unauthenticated code

 

With authentication code generated before authentication, this will be a problem:

https://dev105877.service-now.com/login.do?code=[Authentication Code]

ServiceNow-Log-in.png

Authenticate was successful

https://dev105877.service-now.com/now/nav/ui/classic/params/target/ui_page.do

ServiceNow-Authenticated.png

 

As expected, the post "Allow" provided an authentication code before "Login," the authentication code would be invalid:

"You are not logged in, or your session has expired. Redirecting to the login page"

 

How to correct this problem?

How to correct so that as defined by KB0725643 "Generate Authorization Code" forms are the expected order "Authenticate" then "Allow", so that the authentication code is valid?

1 ACCEPTED SOLUTION

jeff00seattle
Kilo Guru

I resolved this by making the initial OAuth request within a cleared browser (empty of cookies).

 

View solution in original post

1 REPLY 1

jeff00seattle
Kilo Guru

I resolved this by making the initial OAuth request within a cleared browser (empty of cookies).