Google sign-in implementation for an enterprise app that runs both locally and in the cloud

37 views
Skip to first unread message

Pradeep Viswanathan

unread,
Feb 16, 2021, 12:36:58 PM2/16/21
to google-cicp-discussion

I'm trying to implement Google sign-in for an ASP.Net enterprise app that can be installed locally on a Windows/Mac PC or can be hosted on the cloud.

If installed locally, when user launches the app, it runs in a web browser with the following URL:

localhost/myappname

If cloud hosted,

IP address/myappname

Since access origin can vary based on the deployment location of the app, how to specify Access origin URL and redirect URL in Google Developer console? Access-Control-Allow-Origin error will occur if the address from which the Google sign-in is initiated is not configured in the Google Developer Console. I would like to know how Google sign-in should be implemented in such scenarios.

mbazzi

unread,
Feb 17, 2021, 7:18:00 PM2/17/21
to google-cicp-discussion
Hello,

I have reviewed your request and based on my research i found this documentation concerning Cross-origin requests.  A cross-origin request occurs when one domain (for example http://foo.com/) requests a resource from a separate domain (for example http://bar.com/). 

I hope the information above helps.

Pradeep Viswanathan

unread,
Feb 17, 2021, 11:10:43 PM2/17/21
to google-cicp-discussion
Hi mbazzi.. Thanks for the reply. I'm aware of cross-origin requests. What I would like to know is a design recommendation for my app scenario. How Google sign-in can be implemented for my enterprise app without facing CORS issues.?

Fady Abdallah

unread,
Feb 18, 2021, 11:42:24 PM2/18/21
to google-cicp-discussion
I see you have also asked the question on stackoverflow. Going forward, that’s the correct platform to seek help if coding is necessary. Though, when you create an OAuth client ID in console, you can add multiple Authorized JavaScript origins. You may try adding the localhost domain as you have described. Here is an example that implies it is possible. 

Pradeep Viswanathan

unread,
Feb 19, 2021, 6:03:55 AM2/19/21
to google-cicp-discussion
Hi.. I understand that we can add multiple Authorized JavaScript origins. I can only specify the origin if it remains constant. In my case, the origin will differ based on the environment in which my app is deployed. In such case, it is impractical to include all possible origin address in the developer console. If you are not sure about access origin and redirect URL, what's the preferred approach to deploy Google sign-in is my question.

Fady Abdallah

unread,
Feb 24, 2021, 8:50:20 PM2/24/21
to google-cicp-discussion
Yes that makes sense. Apparently a client ID is used to identify a single app to Google's OAuth servers. If your app runs on multiple platforms, each will need its own client ID. In you use-case, you either do this, or you would have to redesign your app to have sign in's happen from a single app instance. I hope this helps.
Reply all
Reply to author
Forward
0 new messages