Search code examples
angularoauth-2.0angular-oauth2-oidc

angular-ouath2-oidc does not redirect after user grants access


I am using angular-oauth2-oicd to request users to grant access to their basecamp3 accounts. The application loads the request for access just fine but when the user clicks grant access it does not redirect back to the index.html page. It does nothing but refresh the page. I have tried lots of things but to no avail.

app.component.ts

export const authConfig: AuthConfig = {
  loginUrl: 'https://launchpad.37signals.com/authorization/new',
  issuer: 'https://launchpad.37signals.com/authorization/token',
  redirectUri: "localhost:8080/index.html",
  clientId: 'aeea63b486afddecf570c500e0ad54c0dd1be7da',
  clearHashAfterLogin: false,
  customQueryParams: {
    'type': 'web_server'
  }

};

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'ng-secure';

  constructor(private oauthService: OAuthService) {
    this.oauthService.configure(authConfig);
    this.oauthService.tokenValidationHandler = new JwksValidationHandler();
    this.oauthService.loadDiscoveryDocumentAndTryLogin();
  }

  login() {
    this.oauthService.initImplicitFlow(encodeURIComponent('localhost8080/index.html'));
  }

  logout() {
    this.oauthService.logOut();
  }

  get givenName() {
    const claims = this.oauthService.getIdentityClaims();
    if (!claims) {
      return null;
    }
    return claims['name'];
  }
}

Solution

  • I figured out why it would not redirect.

    The oauth client will not permit a redirect to localhost. Must be a public ip or actual domain name.