get userinfo and http response return 404 and unrecognized route

Issue #268 invalid
Former user created an issue

I use npm-openid-client to get the userInfo and it works very well in nodejs.It means that my end_point and access_token are right.

/**
**  client_id and client_secret can be empty now
*/
const { Issuer } = require('openid-client');
const end_point = 'xxx'
const access_token = 'xxx'
Issuer.discover(end_point).then(function (issuer) {
    const client = new issuer.Client({
      client_id: 'xx',
      client_secret: 'xx',
    }); 
    client.userinfo(access_token).then(function (userinfo) {
    console.log('userinfo %j', userinfo);
    });
 });

I follow the official website link userinfo request and write some code below:

import java.io.*;
import java.net.*;
import com.nimbusds.oauth2.sdk.http.*;
import com.nimbusds.oauth2.sdk.token.*;
import com.nimbusds.openid.connect.sdk.claims.*;

class Test  {
    public static void main (String[] args) throws Exception{
        String uriStr = "xxx.com";
        String tokenStr = "aabbcc";
        URI userInfoEndpoint = new URI(uriStr);    
        BearerAccessToken token = new BearerAccessToken(tokenStr);

        // response is 404 unrecognized route
        HTTPResponse httpResponse = new UserInfoRequest(userInfoEndpoint, token)
            .toHTTPRequest()
            .send();

        // Parse the response
        UserInfoResponse userInfoResponse = UserInfoResponse.parse(httpResponse);

        if (! userInfoResponse.indicatesSuccess()) {
            // The request failed, e.g. due to invalid or expired token
            System.out.println(userInfoResponse.toErrorResponse().getErrorObject().getCode());
            System.out.println(userInfoResponse.toErrorResponse().getErrorObject().getDescription());
            return;
        }

        // Extract the claims
        UserInfo userInfo = userInfoResponse.toSuccessResponse().getUserInfo();
        System.out.println("Subject: " + userInfo.getSubject());
        System.out.println("Email: " + userInfo.getEmailAddress());
        System.out.println("Name: " + userInfo.getName());
    }
}

the result is that httpResponse return 404 not found , unrecognized route

how can I get the userInfo ?

Comments (2)

  1. Connect2id OSS

    If the HTTP server returns 404, then the URL doesn’t point to the UserInfo endpoint or any meaningful resource / page.

    Check your endpoint URL, with a browser, curl or some other tool.

  2. Former user Account Deleted reporter

    @Connect2id OSS

    sorry, I find devops and update my endpoint url and then it works well now.

    thanks a lot.

  3. Log in to comment