Get user name

54 views
Skip to first unread message

Sample Fox

unread,
Feb 18, 2022, 4:27:33 PM2/18/22
to Freesound API
How do I get the user name after finishing the OAuth2 authentication?

Frederic Font Corbera

unread,
Feb 25, 2022, 6:40:26 AM2/25/22
to freeso...@googlegroups.com
Hi,


Cheers,


frederic

--
Frederic Font - ffont.github.io
Music Technology Group, UPF - mtg.upf.edu
Freesound - freesound.org



On Fri, 18 Feb 2022 at 22:27, Sample Fox <sonick...@gmail.com> wrote:
How do I get the user name after finishing the OAuth2 authentication?

--

---
You received this message because you are subscribed to the Google Groups "Freesound API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to freesound-ap...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/freesound-api/c45708ef-1808-40f5-8a37-ad4a95618134n%40googlegroups.com.

Sample Fox

unread,
Feb 25, 2022, 2:05:24 PM2/25/22
to Freesound API
Hey Frederic! I'm trying to use the /me resource. Unfortunately I get a 401 error. I have the authorization token, and am setting it in the request header as "Authorization: Bearer <token>". Can you post a curl command which works? I've tried everything. I don't know if you know Swift, but this is what my code looks like

func getUserInfo(completion: @escaping (Bool) -> Void) {

        let params = UserParams()

        let request = HttpRequest(baseUrl: config.meURL,

                                  method: .get,

                                  params: params,

                                  headers: [//"Accept": "application/json",

                                            "Authorization": "Bearer \(authToken)"])

        _ = httpClient.performJSONRequest(request: request) { (result: Result<UserModel, HTTPClient.RequestError>) in

            switch result {

            case .success(let success):

                print(success.username)

            case .failure(let failure):

                print("error \(failure)")

            }

        }

    }

Sample Fox

unread,
Feb 25, 2022, 2:12:06 PM2/25/22
to Freesound API
This is a curl command I tried. It shows nothing in response. I'm using a valid token.

curl -H "Authorization: Bearer <token>" "https://freesound.org/apiv2/me"


Reply all
Reply to author
Forward
0 new messages