how to get soundcloud username with passport.js

pufmaigre

I'm working on a nodejs project. I'm using passport.js for my authentication, it works perfectly, but i'm in trouble when I try to get the username of some people using soundcloud.

here is my the part of my code I use to store the profile informations in my database :

function findOrCreateUser (accessToken, refreshToken, profile, done) {
    User.findOne({ oauthID: profile.id }, function(err, user) {
        if(err) console.log(err); 
        if (!err && user != null) done(null, user);
        else {
            var user = new User( {
                oauthID :   profile.id,
                name :      profile.displayName,
                created :   Date.now(),
                pwd :       'no-pwd',
                mail :      '',
                path :      ''
            });
            // temporary path using mongo _id
            user.path = user._id; 
            console.log( "familyName " + profile.familyName  ); // undefined
            console.log( "givenName " + profile.givenName  ); // undefined
            console.log( "middleName " + profile.middleName  ); // undefined
            console.log("displayName "+ profile.displayName  ); // empty if the user didn't fill the field 

            if (profile.displayName == '') user.name = "Jacky Chan";
            // if email exists...(i cant access it on soundcloud but i don't really need it 
            if(typeof(profile.emails) != 'undefined') user.mail = profile.emails[0].value;

            user.save(function(err) {
                if(err) {
                    console.log(err);
                }
                else {
                    console.log("saving user " + user.name );
                    done(null, user);
                };
            });
        };
    });
}

OK so everything is working fine here, profile.displayName return a String according to passport.js documentation. The problem is that this String is obtained with the First Name and the Last Name of the user that are not required, so it's often empty. the only required field is the username.

this picture illustrates it: soundcloud user settings

So my question is :

how to get the username using passport.js ?

any help very appreciated! :)

pufmaigre

Solved!! I had to modify the passeport-soundcloud middleware At line 88 I replaced "full_name" by "username" referring to soundcloud API documentation

:)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

passport js with GET method

From Dev

How to use Laravel Passport with a custom username column

From Dev

Rails how to get SoundCloud track information using SoundCloud song URL

From Dev

How to get Soundcloud embed code by soundcloud.com url

From Dev

How to get Soundcloud embed code by soundcloud.com url

From Dev

Soundcloud API - How to get all Favorite Sets?

From Dev

How to Get a soundcloud like waveforms in Android

From Dev

How to get each track of a playlist with the Soundcloud API?

From Dev

Node.js Passport Display username after successful login

From Dev

Node.js Passport strategy login with either Email or Username

From Dev

Node.js Passport Display username after successful login

From Dev

How to get username in Django

From Dev

How to get %username% in VBScript?

From Dev

How to get Username in Webchat

From Dev

How to get user page in passport

From Dev

How to secure a namespace with passport js?

From Dev

How to convert passport.authenticate username to lower case before submitting?

From Dev

Get better quality from SoundCloud's Waveform.js lib

From Dev

Get link to Facebook profile with passport.js

From Dev

passport.js difficulty to get hashed password

From Dev

Get link to Facebook profile with passport.js

From Java

How to get Keycloak username in AuditorAware

From Dev

How to Get CouchDB Username and Password

From Dev

How to get Windows start username?

From Dev

How to get username from a table

From Dev

How to get username if macros are disabled?

From Dev

How to get username (only) of the Apache?

From Dev

How to get track ID from URL using the SoundCloud API

From Dev

how to get soundcloud audio download url by using audio file id

Related Related

HotTag

Archive