Link to home
Start Free TrialLog in
Avatar of Anand Majmundar
Anand MajmundarFlag for India

asked on

How and where to issue GET request to procure URL for use in Google OAuth Button Click event

Attempting to code click event handler for "Login with Google" button in .NET 4.5 asp.net Web Application. The code would read something as follows:


$('#btnGoogleLogin').click(function () {

    window.location.href = "/api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=http%3a%2f%2flocalhost%3a61358%2fLogin.html&state=GerGr5JlYx4t_KpsK57GFSxVueteyBunu02xJTak5m01";

});

Notice when we click the button we are redirecting the user to /api/Account/ExternalLogin. 


To get this URL, we need to issue a GET request to api/Account/ExternalLogins.


The question is how to issue this GET request and where?

Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Are you using the newest API  .. have you looked at the code generator?
https://developers.google.com/identity/gsi/web/tools/configurator
Avatar of Anand Majmundar

ASKER

Got code from the suggested link:

<div id="g_id_onload"
     data-client_id="MyClientid"
     data-context="signin"
     data-ux_mode="popup"
     data-callback="gcall"
     data-auto_prompt="false">
</div>

<div class="g_id_signin"
     data-type="standard"
     data-shape="rectangular"
     data-theme="outline"
     data-text="signin_with"
     data-size="large"
     data-logo_alignment="left">
</div>

Where to get code for the defined class in the div?

Thank you.
In itself, pasting above code in aspx displays nothing.
Added the following:

 <script src="https://accounts.google.com/gsi/client" async defer></script>

as directed in:

https://developers.google.com/identity/gsi/web/guides/display-button

Yet, no button display.
ASKER CERTIFIED SOLUTION
Avatar of Anand Majmundar
Anand Majmundar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial