0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/connector-google
Darcy Ye 3925424316
refactor(connectors): use zod guard instead of got generic and elaborate error info (#1078)
* feat(alipay): use zod parse instead of got response generic

* feat(alipay): fix expires_in and re_expires_in type

* feat(alipay): extract errorHandler function to map HTTP error to connector error

* feat(alipay-native): refactor as alipay

* feat(aliyun-dm): use zod parser for type guard and extract error handler

* feat(aliyun-sms): extract error handler

* feat(facebook): use zod parser

* feat(github): use zod parser

* feat(google): use zod parser

* feat(wechat-web): use zod parser and wrap error handler

* feat(wechat-native): use zod parser and wrap error handler
2022-06-10 10:41:45 +08:00
..
docs chore(connectors): config template md files to json files (#987) 2022-05-31 12:58:24 +08:00
src refactor(connectors): use zod guard instead of got generic and elaborate error info (#1078) 2022-06-10 10:41:45 +08:00
jest.config.ts refactor: use @silverhand/jest-config (#861) 2022-05-17 17:32:41 +08:00
logo.svg feat(core): serve connector logo (#931) 2022-05-24 13:54:37 +08:00
package.json chore(deps): update dependency lint-staged to v13 (#1019) 2022-06-02 13:19:09 +08:00
README.md docs: google universal connector (#1040) 2022-06-09 13:51:27 +08:00
tsconfig.base.json feat(core): wrap google connector (#674) 2022-04-28 15:16:05 +08:00
tsconfig.build.json feat(core): wrap google connector (#674) 2022-04-28 15:16:05 +08:00
tsconfig.json feat(core): wrap google connector (#674) 2022-04-28 15:16:05 +08:00
tsconfig.test.json test: allow JS in tests (#903) 2022-05-20 13:02:36 +08:00

Google

The Google connector provides a succinct way for your application to use Googles OAuth 2.0 authentication system.

Set up a project in the Google API Console

  • Visit the Google API Console and sign in with your Google account.
  • Click the Select a project button on the top menu bar, and click the New Project button to create a project.
  • In your newly created project, click the APIs & Services to enter the APIs & Services menu.

Configure and register your application

  • On the left APIs & Services menu, click the OAuth consent screen button.
  • Choose the User Type you want, and click the Create button. (Note: If you select External as your User Type, you will need to add test users later.)

Now you will be on the Edit app registration page.

Edit app registration

  • Follow the instructions to fill out the OAuth consent screen form.
  • Click SAVE AND CONTINUE to continue.

Config Scopes

  • Click ADD OR REMOVE SCOPES and select ../auth/userinfo.email, ../auth/userinfo.profile and openid in the popup drawer, and click UPDATE to finish.
  • Fill out the form as you need.
  • Click SAVE AND CONTINUE to continue.

Add Test Users (External user type only)

  • Click ADD USERS and add test users to allow these users to access your application while testing.
  • Click SAVE AND CONTINUE to continue.

Now you should have the Google OAuth 2.0 consent screen configured.

Obtain OAuth 2.0 credentials

  • On the left APIs & Services menu, click the Credentials button.
  • On the Credentials page, click the + CREATE CREDENTIALS button on the top menu bar, and select OAuth client ID.
  • On the Create OAuth client ID page, select Web application as the application type.
  • Fill out the basic information for your application.
  • Click + Add URI to add an authorized domain to the Authorized JavaScript origins section. This is the domain that your logto authorization page will be served from. In our case, this will be ${your_logto_origin}. e.g.https://logto.dev.
  • Click + Add URI in the Authorized redirect URIs section to set up the Authorized redirect URIs, which redirect the user to the application after logging in. In our case, this will be ${your_logto_origin}/callback/google-universal. e.g. https://logto.dev/callback/google-universal.
  • Click Create to finish and then you will get the Client ID and Client Secret.

Settings

Name Type
clientId string
clientSecret string

References