OAuth: Getting Access Token

I am writing an example OpenID based client that registers itself with a diaspora pod, gets user authorization to grant access to user’s posts, gets an access token from the pod, then downloads and displays posts.

I’m trying to replicate the process outlined here:

Server is diaspora version “”

Requesting access tokens fail with an “invalid_client” error. I’m uncertain why. If someone could provide guidance in this matter I’d be very thankful.

The relevant part of the OAuth process goes like this:

Posted To Diaspora Server
http_post_json(): POST

Diaspora Server Response



User Confirmation Opened in Web Browser:

The code challenge:

is hard coded (not in git repo) SHA256 hash + Base64 encoded random string:

SHA256 + Base64 encoding was generated by this page:

Redirect URL With Client Confirmation Code
GET /?code=9d47e736f02bbb6e90032fbca96f1cf1687c4a3d3b6fda3947f09791554b1564&state=bbbc1d2a HTTP/1.1

Access Token Request Posted To Diaspora Server
http_post_enc(): POST

urlencoded data:

Diaspora Server Response
"error_description":"The client identifier provided is invalid, the client failed to authenticate, the client did not include its credentials, provided multiple client credentials, or used unsupported credentials type."

I didn’t verify but I think you’re missing the client_secret in the request to the access token.

In the registration endpoint you should have a token_endpoint_auth_method method field. If your request didn’t specify one, the default should be client_secret_post, so the client secret is required when exchanging the authorization code for an access token. (When exchanging the refresh token for a new access token too, I think).

OpenID Connect probably deviates here a bit from standard OAuth2.

Spec references:

1 Like

Yes! It works! I can now access things through the API. Thank you so much.

Let me know if there’s anything in the API I can test for you.

Next question - I see that the id_token field contains a JSON Web Signature (JWS) which according to the RFC relies on cryptography for validation.

I’m not a cryptographer. I see here that there’s a JavaScript library called openid-client but it depends on Node.js. I don’t currently have experience with Node.js but from reading the introductory material it seems far too extensive for a small application like this.

Do you or anyone else here have a preferred javascript/C/C++ library which fits within the scope of a standalone client app that can verify the JWS signature?

Again, thank you for the help.

No, I didn’t dive much into that part of the authorization process either yet :confused:

Just generally watch out for inconsistencies or anything that makes client implementation life hard, so mostly “Oh I wish this was returned here instead of me having to do another API call” and “I can’t get the right information to do X” kind of stuff. I think there also still might be some rough edges around error handling and maybe scopes/authorization. Just mention anything you notice at this point really :slight_smile: