官术网_书友最值得收藏!

Tell the authorization providers about your app

Before we ask an authorization provider to help our users sign in, we must tell them about our application. Most providers have some kind of web tool or console where you can create applications to kick this process off. Here's one from Google:

In order to identify the client application, we need to create a client ID and secret. Despite the fact that OAuth2 is an open standard, each provider has their own language and mechanism to set things up. Therefore, you will most likely have to play around with the user interface or the documentation to figure it out in each case.

At the time of writing, in Google Cloud Console, you navigate to API Manager and click on the Credentials section.

In most cases, for added security, you have to be explicit about the host URLs from where requests will come. For now, since we're hosting our app locally on localhost:8080, you should use it. You will also be asked for a redirect URI that is the endpoint in our chat application and to which the user will be redirected after they successfully sign in. The callback will be another action in loginHandler, so the redirect URL for the Google client will be http://localhost:8080/auth/callback/google.

Once you finish the authorization process for the providers you want to support, you will be given a client ID and secret for each provider. Make a note of these details because we will need them when we set up the providers in our chat application.

Note

If we host our application on a real domain, we have to create new client IDs and secrets or update the appropriate URL fields on our authorization providers to ensure that they point to the right place. Either way, it is good practice to have a different set of development and production keys for security.

主站蜘蛛池模板: 上犹县| 大安市| 定结县| 兴安县| 张掖市| 岗巴县| 绥阳县| 西畴县| 黄石市| 新余市| 会同县| 英吉沙县| 琼结县| 五大连池市| 三门县| 集安市| 汪清县| 卫辉市| 东乡族自治县| 黄大仙区| 新泰市| 舟曲县| 北流市| 德阳市| 宕昌县| 顺昌县| 五河县| 金乡县| 南投县| 梨树县| 乌海市| 康保县| 鸡西市| 兴义市| 凌源市| 南江县| 乌审旗| 基隆市| 北流市| 苍山县| 重庆市|