Using Okta SKD with @angular/http

It seems that all examples are using @angular/common/http is there an example on how to use Okta SDK with older @angular/http?

The issue I am having is that I don’t want to change my methods to async/await and hence can’t execute await this.oktaAuth.getAccessToken();

I understand it is possible to extend http and implement “Interceptor” functionality but is there an example of how to do that with Okta SDK?



this.oktaAuth.getAccessToken().then(() => {
  // do something


import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';

import { AuthService } from 'auth';

import { LoggerService } from 'utils';

export class AuthInterceptor implements HttpInterceptor {

  constructor(private authService: AuthService,
              private logger: LoggerService) {'AuthInterceptor: constructor()');

  intercept(req: HttpRequest<any>, next: HttpHandler) {

    const accessToken = this.authService.getAccessToken();

    if (accessToken) {'AuthInterceptor: intercept() Bearer ' + accessToken);

      const authReq = req.clone({ setHeaders: { Authorization: 'Bearer ' + accessToken } });
      return next.handle(authReq);

    return next.handle(req);


The Angular wrapper for @okta/okta-auth-js doesn’t support the Authorisation Code flow with PKCE so you will need to write your own wrapper for @okta/okta-auth-js.

For example: Angular Wrapper for Okta Auth JavaScript SDK

Auth Resources