Okta API - authn always returns Invalid Session

I am trying to authenticate a user using the "authn" API:

POST MYACCOUNT.oktapreview.com/api/v1/authn
{
  "username": "email@gmail.com",
  "password" : "Password123"
}

      

But this always returns

{
    "errorCode": "E0000005",
    "errorSummary": "Invalid session",
    "errorLink": "E0000005",
    "errorId": "oael83e1QQxSNuHOlE0VkqBuA",
    "errorCauses": []
}

      

Any idea why this is happening?

When I create a session, I just get a 403 - Forbidden error.

The session API works, but I want to use the authn API for individual login.

Thank you for your help.

+3


source to share


4 answers


The problem came from the authorization header in the Okta request.



The authorization header should be "Authorization: SSWS API_TOKEN" Instead, I just sent "Authorization: API_TOKEN"

+5


source


I had the same error 403 - Forbidden

. It worked fine in Fiddler, but not in my script (Powershell)

The url I used was http

, but the resource was actually on https

. Fiddler moved me with my header information to the https site. In Powershell, I lost the title and got a forbidden error.



So changing the url to https

fixed it for me.

0


source


Expanding on @paramesh's answer (since this is 100% correct), if you are using postman then I added "Authorization: SSWS API_TOKEN" as a preset header and then added it when it was missing.

to do this in postman extension for chrome: 1. Click the "headers" button far to the right 2. Click "manage presets" 3. Click "add" 4. Fill in the information (if you imported okta environment like in your api test client instructions ) , then it will look like this: SSWS {{apikey}} 5. Check the headers on other methods, if the authorization header is not there, add it by clicking the "add preset" button I'm sorry, I don't have enough reputation to leave a comment on the correct answer ...

0


source


My problem was that I was not using the Okta preview url as I was in the preview environment.

https://${org}.okta.com/api/v1/users

      

Should be changed to

https://${org}.oktapreview.com/api/v1/users

      

0


source







All Articles