I’m trying to exchange an auth code for an access token in an Angular 1.5 app (without using the Okta SDK or widget).
It should be pretty straight-forward - redirect to Okta’s log in UI, receive access code and then XHR POST to /oauth2/v1/token and eventually also to the refresh endpoint.
I believe you need to use the default AS for this functionality, rather than your Org’s AS. Does posting to https://dev-123456.oktapreview.com/oauth2/default/v1/token. work?
The /token endpoint is not CORS enabled, and therefore not intended to be accessed directly by the browser. There were few reasons why this was disabled, all centric around keeping an application secure.
But wouldn’t an Authorization Server be expected to allow this?
According to the last OAuth specs, SPA should move to Auth Code flow with PKCE key, right? How can we accomplish the auth dance without allowing token requests from the browser?
The /token endpoint is now CORS enabled for Authorization code flow with PKCE since version 2019.03.2 in Okta preview and 2019.04.0 in production. You can find further details about this release here.