okta / okta-react

Okta OIDC SDK for React
https://github.com/okta/okta-react
Other
119 stars 79 forks source link

Unable to get OKTA sign in widget. #125

Open pbollaram opened 3 years ago

pbollaram commented 3 years ago

Hi, I am setting up OKTA login with my app and for some reasons i am unable to view sign in widget. I see GET https://.oktapreview.com/.well-known/openid-configuration call is keep getting cancelled(abandoned) for no reason.

image

image

Here is my configuration.

const oktaAuth = new OktaAuth({
  issuer: 'https://<domain>.oktapreview.com',
  clientId: process.env.REACT_APP_OKTA_CLIENT_ID,
  redirectUri: window.location.origin + '/implicit/callback',
    pkce: true,
  scope: ['openid', 'profile', 'email', 'groups'],
  cookies: {
    secure: window.location.protocol === 'https:',
  },
  tokenManager: {
    autoRenew: true,
    secure: true,
    storage: 'localStorage',
  },
});

const App =()=>{
  const history = useHistory();
  const restoreOriginalUri = async (_oktaAuth, originalUri) => {
    history.replace(toRelativeUrl(originalUri, window.location.origin));
  };
   <Security oktaAuth={oktaAuth} restoreOriginalUri={restoreOriginalUri}>
       <Switch>
                <Route path='/' exact={true} component={Home}/>
                <Route path='/implicit/callback' component={LoginCallback}/>
                <Route path='/dashboard' component={Dashboard}/>
         </Switch>
     </Security>

}

Home.js

function Home(){
 const login = async () => { await oktaAuth.signInWithRedirect(); }
  return(
  <button onClick={login} ></button>
  )
}

Okta package that i am using.

@okta/okta-auth-js": "^4.8.0", @okta/okta-react": "^5.0.0",

amcdnl commented 3 years ago

See: https://github.com/okta/okta-react/issues/118#issuecomment-833525461

pbollaram commented 3 years ago

@amcdnl upgrading to @okta/okta-react: '^5.1.1' and @okta/okta-auth-js: '^4.9.0' did not work. i still dont see sign in widget.

pbollaram commented 3 years ago

i have downgraded Okta version and still i see all of .well-known/openid-configuration calls care getting cancelled.

Request URL: https:///.well-known/openid-configuration Referrer Policy: strict-origin-when-cross-origin Provisional headers are shown accept: application/json content-type: application/json Referer: http://localhost:3000/ sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90" sec-ch-ua-mobile: ?0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 x-okta-user-agent-extended: @okta/okta-react/3.0.8 okta-auth-js/3.2.6