Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feedback on How to Access the Azure Functions App with Google Authentication Using JavaScript #125065

Open
Sampath280 opened this issue Dec 5, 2024 · 2 comments

Comments

@Sampath280
Copy link

Type of issue

Missing information

Feedback

I created a sample Azure Function locally and deployed it to Azure using the URL https://.azurewebsites.net/.auth/#/google/callback. After that, I was able to access the URL: https://.azurewebsites.net/api/. The Function App URL is now working as expected, and here are the logs:

image

I am trying to access the https://.azurewebsites.net/api/, which should return a JSON response: Hello, using JavaScript.

I have tried using both @react-oauth/google and passport-google-oauth2.

const GoogleStrategy = require( 'passport-google-oauth2' ).Strategy;

//Middleware
app.use(session({
    secret: "secret",
    resave: false ,
    saveUninitialized: true ,
}))

app.use(passport.initialize()) // init passport on every route call
app.use(passport.session())    //allow passport to use "express-session"


//Get the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET from Google Developer Console
const GOOGLE_CLIENT_ID = "3184701-tn6finlstvgcgvte2381.apps.googleusercontent.com"
const GOOGLE_CLIENT_SECRET = "XyLuTLHX6Ov_93IP"

authUser = (request, accessToken, refreshToken, profile, done) => {
    return done(null, profile);
  }

//Use "GoogleStrategy" as the Authentication Strategy
passport.use(new GoogleStrategy({
    clientID:     GOOGLE_CLIENT_ID,
    clientSecret: GOOGLE_CLIENT_SECRET,
    callbackURL: "http://localhost:3001/auth/google/callback",
    passReqToCallback   : true
  }, authUser));


passport.serializeUser( (user, done) => { 
    console.log(`\n--------> Serialize User:`)
    console.log(user)
     // The USER object is the "authenticated user" from the done() in authUser function.
     // serializeUser() will attach this user to "req.session.passport.user.{user}", so that it is tied to the session object for each session.  

    done(null, user)
} )

However, I am receiving a 403 error. I am trying to use either @react-oauth/google or passport-google-oauth2. Any help would be appreciated. Thank you!

Page URL

https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/app-service/configure-authentication-provider-google.md

Content source URL

https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-provider-google

Author

Rageking8

Document Id

2b2f9abf-9120-4aac-ac5b-4a268d9b6e2b

@Sampath280 Sampath280 changed the title **Feedback on How to Access the Azure Functions App with Google Authentication Using JavaScript** Feedback on How to Access the Azure Functions App with Google Authentication Using JavaScript Dec 5, 2024
@TPavanBalaji
Copy link
Contributor

@Sampath280
Thanks for your feedback! We will investigate and update as appropriate.

@PesalaPavan
Copy link
Contributor

@Sampath280
Thanks for your feedback! I've assigned this issue to the author who will investigate and update as appropriate.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants