I Have an angluar application with PKCE authO configuration, I have configured the application with github auth provider, when clicking the login button in the application it will redirect to the github auth provided login page, after authenticated the github credential it will redirect to the page 404 , I want to redirect my given url in the auth service
login.ts
codeVerifier: string | undefined;
codeChallenge: string | undefined;
constructor(private pkceService:PkceService , private authService: AuthServiceService){
// this.codeVerifier = this.pkceService.generateCodeVerifier();
// this.codeChallenge = this.pkceService.generateCodeChallenge(this.codeVerifier);
}
login(){
// Generate PKCE code verifier and code challenge
const codeVerifier = this.pkceService.generateCodeVerifier();
const codeChallenge = this.pkceService.generateCodeChallenge(codeVerifier);
// Save the code verifier in session storage for later use in token exchange
sessionStorage.setItem('codeVerifier', codeVerifier);
// Redirect the user to the authorization endpoint
this.authService.initiallogin(codeVerifier, codeChallenge);
}
authService.ts```
initiallogin(codeVerifier: string, codeChallenge: string) {
const authorizationEndpoint = 'https://github.com/login/oauth/authorize';
const redirectUri = 'https://wbidmaxapp.com';
const scope = 'public_repo'; // Define required scopes
const responseType = 'code';
const state = this.generateRandomString(16); // Include a state for CSRF protection
// Save the code verifier in session storage for later use in token exchange
sessionStorage.setItem('codeVerifier', codeVerifier);
// Construct the authorization URL with the required parameters
const url =
`${authorizationEndpoint}?` +
`response_type=${responseType}` +
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
`&scope=${encodeURIComponent(scope)}` +
`&code_challenge=${encodeURIComponent(codeChallenge)}` +
`&code_challenge_method=S256` + // Use SHA-256 for code challenge
`&state=${state}`;
// Redirect the user to the authorization endpoint
window.location.href = url;
}
generateRandomString(length: number): string {
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += charset.charAt(Math.floor(Math.random() * charset.length));
}
return result;
}
I want to redirect the application in to the given uri