Auth0 Home Blog Docs

How to retrieve access_token using google connection?

I am a backend developer and I need to retrieve an access token for my backend to test how it works.

I successfully configured google-oauth2 connection (“Try” button works well).
I’ve found the route for retrieving token: /oauth/token, but I need to obtain a valid code for it.

How can I do that? I found some route to do that but it won’t work for me:

https://myapp.eu.auth0.com/authorize?
  response_type=code&
  client_id=myclientid&
  connection=google-oauth2&
  redirect_uri=localhost

I see "Oops!, something went wrong" error while going through it.

I’ve tried to create a simple HTML page with code example from docs:

// Script uses auth0.js. See Remarks for details.
<script src="https://cdn.auth0.com/js/auth0/9.5.1/auth0.min.js"></script>
<script type="text/javascript">
  // Initialize app
  var webAuth = new auth0.WebAuth({
    domain:       'myapp .eu.auth0.com',
    clientID:     'p2...',
	responseType: "code"
  });

  // Trigger login with google
  webAuth.popup.authorize({
    connection: 'google-oauth2'
  });

</script>

And I still have the same error:
enter image description here

Could somebody help me?

Solved. I just figured out that I can check Logs on auth0 side.

1 Like

Glad you made it! Feel free to ask any other questions down the road!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.