Giter Club home page Giter Club logo

Comments (5)

dadvir avatar dadvir commented on May 29, 2024 1

thank you for your help, I've deleted the db docker image and recreated it from scratch with a fresh set of config, and succeeded with calling the API :)

from logto.

xiaoyijun avatar xiaoyijun commented on May 29, 2024

Hi @dadvir , have you create an application role with the Management API permission (all)? And when you trying to fetch the access token, remember to use the all as the scope param value.

Create an M2M application

image

Create an applicaiton role with the Management API permission

image

Assign the role above to your M2M App

image

Request access token with all scope and the management api resource

curl --location '[your-logto-endpoing]/oidc/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic ${generateBasicAuth(m2mAppId, m2mAppSecret)}' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'resource=https://[your-tenant-id].logto.app/api' \
--data-urlencode 'scope=all'

from logto.

dadvir avatar dadvir commented on May 29, 2024

Thank you for the quick response :)

I've tried these again and got to the same issue, please see attached screen shots of the config and outcome.

The application:

image

Its roles:

image

The API with role (too.. didn't see this on your end, but saw it in the getting started guide...):

image

The role with all access:

image

And the machine-to-machine access:

image

from logto.

dadvir avatar dadvir commented on May 29, 2024

@xiaoyijun I've created another app and followed your instructions again, with a "fresh" app, and got the same result.
your help will be highly appreciated here :)

from logto.

xiaoyijun avatar xiaoyijun commented on May 29, 2024

@dadvir You have setup the app correctly, maybe the error is because you're using the m2m app in a wrong way.
Here is what i did:

Step 1: Request an access token from Logto core service by the M2M app

image image

Code snippet:

curl --location 'http://localhost:3001/oidc/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic OWxydTU5ZG91NzF1bDl0YXJkYTZ3OktEQ29oOGxNNllWVkFSVDM1cjdJWGI5ZlF6azZhcTVU' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=all' \
--data-urlencode 'resource=https://default.logto.app/api'

And you will get the access token:
image

Step 2: Fetch application data using the access token

image

Code snippet:

curl --location 'http://localhost:3001/api/applications' \
--header 'Authorization: Bearer eyJh[Hide for brevity]-fUU'

Logto Console configuration

image image

from logto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.