Weibo uses Oauth2.0 to authorize third parties, with specific information referring to Oauth2 and Weibo official documents.
Meteor's user system integrates third-party account binding capabilities. In fact, in the Meteor user system, the user is authenticated by the service associated with the account (login), the service can be Weibo, Twitter, Google and other third-party accounts, or it can be password ( You can build a user system that does not contain password service and is purely based on a third-party account). As for your meteor user system to integrate which services, you can install the accounts-<service> package at your discretion.
If you use Accounts-password, you need to create a user, and then log in using username (or email) and password. However, if you use a third-party account, you do not have to create an account, you can directly loginwith<service>, the system will obtain your authorization (and to the third-party licensing server to obtain access tokens and related user information), Check whether there is a bound account based on the third party ID, or, if so, log in, or create and log in.
Meteor does not provide a facility (which is technically feasible) to bind existing accounts and third-party accounts. As mentioned above, login directly with a third-party account, Meteor will create a new account. Solution by yourself Google, here is a scenario I chose--using the meteor-link-accounts package.
Here are the details of the operation:
Meteor after installation, there is a user system. First, you need to support password. Install the Accounts-password package.
Then, you need to support Weibo. Install the Accounts-weibo package.
Then, you need to register the developer account with Weibo and apply for the app, select < Web application > apply. After successful application, you can get key and secret, and can set Redirect_url (authorization callback page). It is particularly important to note that during the development phase, it is recommended to set Redirect_url to Http://127.0.0.1:3000/_oauth/weibo and use 127.0.0.1:3000 on the local computer to open the app. The host field can be set by itself, but the machine must be properly configured so that the host is mapped to a native IP, and the Meteor app uses that host as the base URL, and the host uses it to open the app.
Depending on the meteor documentation, the use of a third-party account requires proper configuration. First, install the Service-configuration package, and then, on the server side, configure the following:
ServiceConfiguration.configurations.upsert (
{service: "Weibo"},
{
$set: {
ClientId: < your app id>
Secret: < your app secret>
Loginstyle: "Popup"
}
}
);
Now you should be able to sign in with Weibo by calling Meteor.loginwithweibo () on the front-end!
Next, increase the ability to bind Weibo to an existing account. First, install the Bozhao:link-accounts package, and then, you are done! You can already call Meteor.linkwithweibo () for Weibo binding after the client has logged on. After the binding succeeds, Weibo is incremented under the user's Services property. Please check the database yourself for details.
Todo
Next, the need to increase the microblog unbind function, I have not done, but the specific idea is this.
First, you can wait for bozhao:link-accounts to implement this function.
If it is urgent, it is not difficult to implement it yourself. The backend needs to provide a method to delete the Weibo field of the login user's services. You can check if the account has a password service before deleting it to prevent it from becoming a wild account (without any references).
Further, you can choose to revoke the requested Weibo access token when you unbind. You can call the relevant interface.
Meteor: Bundled Weibo