Title: Meteor yammer authentication
Tags: meteor
Question: How do I use custom yammer authentication with Yammer?
Meteor seems to do basic things well, but any complications and it dies.
So far the code I have is the following. I have no idea how Meteor can set the current user id to the variables that are return from the REST call.
Client:
console.log "auth running"
tokenMatch = window.location.hash.match(/access_token=([a-zA-Z0-9]+)/)
if tokenMatch
authToken = tokenMatch[1];
console.log "auth token", authToken
Meteor.loginWithToken(authToken);
Meteor.call 'yammerAuth', authToken, (err, result) -&gt;
console.log "data", result, err
Meteor.call 'hello', (err,data) -&gt;
console.log data
console.log "client"
Server:
Meteor.methods
yammerAuth: (authToken) -&gt;
console.log "yammerAuth", authToken
result = Meteor.http.call "GET", 'https://www.yammer.com/api/v1/users/current.json',
headers:
Authorization: 'Bearer ' + authToken
data = result.data
console.log "login", data
Accounts.createUser
username: data.id
email: "blah"
password: "blah"
profile: data
return result
hello: -&gt;
console.log "hello"
"hello"
Comment: let me know I will do it for you.


Here is another answer: Server:
Accounts.registerLoginHandler (loginRequest) -&gt;
authToken = loginRequest.authToken
return unless authToken
result = Meteor.http.call "GET", 'https://www.yammer.com/api/v1/users/current.json',
headers:
Authorization: 'Bearer ' + authToken
data = result.data
# console.log "login", data
serviceData =
id: data.id
accessToken: authToken
email: data.name + "@microsoft.com"
options =
profile:
name: data.full_name
network: data.network_name
pic: data.mugshot_url
return if data.network_name != "Microsoft" # Only microsoft users allowed
console.log serviceData, options
user = Accounts.updateOrCreateUserFromExternalService('yammer', serviceData, options)
# console.log "user", user
return userId:user.userId
Client:
tokenMatch = window.location.hash.match(/access_token=([a-zA-Z0-9]+)/)
if tokenMatch
authToken = tokenMatch[1];
console.log "auth token", authToken
Accounts.callLoginMethod
methodArguments: [{authToken:authToken}]
window.location.hash = "";
Login Button
a class="login-btn" href="https://www.yammer.com/dialog/oauth?client_id=[client_id]&amp;redirect_uri=[uri]&amp;response_type=token"&gt;</a

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:07/30/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<meteor>', 'Title': 'Meteor yammer authentication', 'ViewCount': 197, 'id': 25030425, 'user_AboutMe': None, 'user_AccountId': 163887.0, 'user_DisplayName': 'noj', 'user_Reputation': 139.0, 'user_Views': 23.0, 'user_id': 386320.0}}