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

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.

主站蜘蛛池模板: 昆明市| 济阳县| 大同县| 靖宇县| 裕民县| 石河子市| 乌兰察布市| 广河县| 盱眙县| 宁海县| 马龙县| 黄平县| 广州市| 博罗县| 淮南市| 杂多县| 尤溪县| 台湾省| 泊头市| 灵武市| 福安市| 清远市| 黑河市| 泸水县| 渝中区| 专栏| 鹤岗市| 浦城县| 天祝| 满洲里市| 乌鲁木齐县| 金坛市| 蒙自县| 贵德县| 大竹县| 巴塘县| 绥滨县| 固阳县| 合水县| 永修县| 离岛区|