More renaming to meteorid, and update to new api endpoints

This commit is contained in:
Emily Stark
2013-12-06 16:00:25 -08:00
parent 7142c1667e
commit e46264d283
6 changed files with 22 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
Accounts.oauth.registerService("meteorid");
Accounts.oauth.registerService("meteorId");
if (Meteor.isClient) {
Meteor.loginWithMeteorId = function (callback) {
Meteor.loginWithMeteorId = function (options, callback) {
var credentialRequestCompleteCallback =
Accounts.oauth.credentialRequestCompleteHandler(callback);
MeteorId.requestCredential(credentialRequestCompleteCallback);
@@ -10,11 +10,11 @@ if (Meteor.isClient) {
Accounts.addAutopublishFields({
// publish all fields including access token, which can legitimately be used
// from the client (if transmitted over ssl or on localhost).
forLoggedInUser: ['services.meteorid'],
forLoggedInUser: ['services.meteorId'],
forOtherUsers: [
'services.meteorid.username',
'services.meteorid.profile',
'services.meteorid.id'
'services.meteorId.username',
'services.meteorId.profile',
'services.meteorId.id'
]
});
}

View File

@@ -1,3 +1,3 @@
#login-buttons-image-meteorid {
#login-buttons-image-meteorId {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAEJGlDQ1BJQ0MgUHJvZmlsZQAAOBGFVd9v21QUPolvUqQWPyBYR4eKxa9VU1u5GxqtxgZJk6XtShal6dgqJOQ6N4mpGwfb6baqT3uBNwb8AUDZAw9IPCENBmJ72fbAtElThyqqSUh76MQPISbtBVXhu3ZiJ1PEXPX6yznfOec7517bRD1fabWaGVWIlquunc8klZOnFpSeTYrSs9RLA9Sr6U4tkcvNEi7BFffO6+EdigjL7ZHu/k72I796i9zRiSJPwG4VHX0Z+AxRzNRrtksUvwf7+Gm3BtzzHPDTNgQCqwKXfZwSeNHHJz1OIT8JjtAq6xWtCLwGPLzYZi+3YV8DGMiT4VVuG7oiZpGzrZJhcs/hL49xtzH/Dy6bdfTsXYNY+5yluWO4D4neK/ZUvok/17X0HPBLsF+vuUlhfwX4j/rSfAJ4H1H0qZJ9dN7nR19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GqVRKGlkRCFwm27zZkZ/rV/eyXWXP75Zr6ZNQAA8PdP0zTxBYNB9c3j8Sj9V/x7ApPJJIGhYEhkoVDAer0uutfrRbPZ/JaI4k1IB9xuN1itVrher1QA4H6/w/l8hsViAcfjETKZDBAjOBwOcLlcJIYvjcFOp1M+7HY7keFwWMC9Xg+SySSs12sBUHXgeOOxMPh0OkGxWIRAIADz+RxmsxnUajUolUoSy8z42Gw2KcY6MyX2AJFIRHpqt9vcCm63WxyPx0hsxOZrMpm89e3z+dBisTx9DocDiYUYo9FIgVihOYhNfWOr1UJihLlcTiV7JQE0PhFX43O73UQ+Hg+RfNFQke1utytJqGWkJ9dgv99DPB7n1uD78i1Sv7hPwoppt9vlBZbLpdgyA9KQpi4Zy+WyVFAlSdEZcPXBYID5fF5i/X6/SJ4shkLPpZlOp4JdrVZYrVZxOByqXP1+/wmggvrgZWN5iMwilUrh178v7HQ6mM1mxffx5wM3m40kaTab4kskEiJ5ARnHvSCzeBlKptNp0RuNhiT4/PspNrdrACMvg3ygZcFoNIqxWExehenx7nNi3otKpSK66v1ZnX0/fyb+o0hfL5++HxyjA/WCBtxPAoNT0XS5XGrR1PYZiv4Hdhyfo4t1ww8AAAAASUVORK5CYII=);
}

View File

@@ -5,7 +5,7 @@ MeteorId = {};
// completion. Takes one argument, credentialToken on success, or Error on
// error.
MeteorId.requestCredential = function (credentialRequestCompleteCallback) {
var config = ServiceConfiguration.configurations.findOne({service: 'meteorid'});
var config = ServiceConfiguration.configurations.findOne({service: 'meteorId'});
if (!config) {
credentialRequestCompleteCallback &&
credentialRequestCompleteCallback(
@@ -17,11 +17,11 @@ MeteorId.requestCredential = function (credentialRequestCompleteCallback) {
var credentialToken = Random.id();
var loginUrl =
METEORID_URL + "/authorize?" +
METEORID_URL + "/oauth2/authorize?" +
"state=" + credentialToken +
"&response_type=code&" +
"client_id=" + config.clientId +
"&redirect_uri=" + Meteor.absoluteUrl("_oauth/meteor/close");
"&redirect_uri=" + Meteor.absoluteUrl("_oauth/meteorId/close");
Oauth.showPopup(
loginUrl,

View File

@@ -1,4 +1,4 @@
<template name="configureLoginServiceDialogForMeteor">
<template name="configureLoginServiceDialogForMeteorId">
<p>
First, you'll need to get a MeteorId Client ID.
Set Authorized Redirect URIs to:

View File

@@ -1,8 +1,8 @@
Template.configureLoginServiceDialogForMeteor.siteUrl = function () {
Template.configureLoginServiceDialogForMeteorId.siteUrl = function () {
return Meteor.absoluteUrl();
};
Template.configureLoginServiceDialogForMeteor.fields = function () {
Template.configureLoginServiceDialogForMeteorId.fields = function () {
return [
{property: 'clientId', label: 'Client ID'},
{property: 'secret', label: 'Client secret'}

View File

@@ -1,6 +1,6 @@
MeteorId = {};
Oauth.registerService("meteorid", 2, null, function (query) {
Oauth.registerService("meteorId", 2, null, function (query) {
var response = getTokens(query);
var accessToken = response.accessToken;
var identity = getIdentity(accessToken);
@@ -20,7 +20,8 @@ Oauth.registerService("meteorid", 2, null, function (query) {
return {
serviceData: serviceData,
options: {profile: {name: identity.name}}
options: {profile: {name: serviceData.username}}
// XXX use username for name until meteor accounts has a profile with a name
};
});
@@ -30,22 +31,20 @@ Oauth.registerService("meteorid", 2, null, function (query) {
// - refreshToken, if this is the first authorization request and we got a
// refresh token from the server
var getTokens = function (query) {
var config = ServiceConfiguration.configurations.findOne({service: 'meteor'});
var config = ServiceConfiguration.configurations.findOne({service: 'meteorId'});
if (!config)
throw new ServiceConfiguration.ConfigError("Service not configured");
var response;
try {
response = HTTP.post(
METEORID_URL + "/token", {
METEORID_URL + "/oauth2/token", {
params: {
grant_type: "authorization_code",
code: query.code,
client_id: config.clientId,
client_secret: config.secret,
redirect_uri: Meteor.absoluteUrl("_oauth/meteor/close", {
secure: true
})
redirect_uri: Meteor.absoluteUrl("_oauth/meteorId/close")
}
}
);
@@ -58,7 +57,8 @@ var getTokens = function (query) {
if (! response.data || response.data.error) {
// if the http response was a json object with an error attribute
throw new Error("Failed to complete OAuth handshake with MeteorId. " +
response.data.error);
(response.data ? response.data.error :
"No response data"));
} else {
return {
accessToken: response.data.access_token,
@@ -71,7 +71,7 @@ var getTokens = function (query) {
var getIdentity = function (accessToken) {
try {
return HTTP.get(
METEORID_URL + "/identity",
METEORID_URL + "/api/v1/identity",
{params: {access_token: accessToken}}).data;
} catch (err) {
throw _.extend(new Error("Failed to fetch identity from MeteorId. " + err.message),