Can not get user profile using discord access token - rest

I am building an application using discord oauth. I used discord-oauth2 node module to get access_token from discord and was able to get user data from /users/#me endpoint.
So the request would look like this
Request URL: https://discord.com/api/v9/users/#me
Request Headers
authorization: `access_token here`
The above request works but if I change the url to https://discord.com/api/v9/users/{user_id}/profile to get user profile, it returns 401: Unauthorized error.

Related

How to connect to SharePoint in Postman using user id and password instead of client id and client secret?

I want to connect to SharePoint by using username#company.com and password instead of client id and client secret. Do I need to get any authorization for my ID? If yes, how to get? I know the process for fetching authorization for client ID and client secret.
In this URL: https://{tenant}.sharepoint.com/sites/{sitename}/_layouts/15/user.aspx
I add my user id and password with permission levels as "Full control".
But in this URL: https://{tenant}.sharepoint.com/sites/{sitename}/_layouts/15/appprincipals.aspx
I am able to see only client id and client secret. Not my user id.
When I send POST request using Postman it is giving me "error": "unsupported_grant_type".
Postman Inputs:
POST https://accounts.accesscontrol.windows.net/{tenant_id}/tokens/OAuth/2
Headers
Content-Type : application/x-www-form-urlencoded
Body (x-www-form-urlencoded)
grant_type: password
username: username#company.com
password: password
resource:00000003-0000-0ff1-ce00-000000000000/{tenant}.sharepoint.com#{tenant_id}
SharePoint rest api does not support "Password Grant Flow". You can either use "Client Credentials Flow" or "Implicit Flow".
If you want to allow users to use their username & password, Use implicit flow.
NOTE: User will always require to sign in to get access token. You can not simply pass username and password with post request.
Here is the complete guide for configuring azure ad app for implicit flow : https://frankchen2016.medium.com/how-to-access-the-spo-rest-api-using-implicit-authentication-flow-40d65750554f

Keycloak API get each role for a specific user

I try to access every role for the user 7b244fd8-5e1a-43af-9572-91d50784fda7 and found this code (Keycloak User Roles missing in REST API):
GET /auth/admin/realms/{realm}/users/{user-uuid}/role-mappings/clients/{client-uuid}
This is why I try to make the following GET request (Bearer token correctly provided)
https://mywebsite.com/auth/admin/realms/master/users/7b244fd8-5e1a-43af-9572-91d50784fda7/role-mappings/clients/admin-cli
I get an {"error": "Client not found" } error.
I guess the "admin-cli" in my code is wrong, but this is the Client ID in the master realm. Is this the wrong id? How can I make the request to get all roles for a specific user working?
I get an {"error": "Client not found" } error.
I guess the "admin-cli" in my code is wrong, but this is the Client ID
in the master realm. Is this the wrong id? How can I make the request
to get all roles for a specific user working?
You should use the ID of the client and not the client ID, which you can find on the url:
or via Rest Admin API:
GET /auth/admin/realms/{realm}/clients?clientId=$CLIENT_ID
The /auth path was removed starting with Keycloak 17 Quarkus distribution, in that case the endpoint would be:
GET /admin/realms/{realm}/clients?clientId=$CLIENT_ID

Facebook Graph API Error - No redirect uri

I'm throughly stumped. I can run this simple GET request in postman and have no issue, but when making it from the rails api running locally it fails with this error. I have tried using my localhost, ipadress and in this latest attempt just the route and still having an issue.
Here is the documatation on this request
The Error
{ "error":
{
"message": "Missing redirect_uri parameter.",
"type":"OAuthException",
"code":191,
"fbtrace_id":"BjAByCFGkQL"
}
}
The Request
https://graph.facebook.com/oauth/access_token?client_id=123456789&client_secret=123456789&redirect_uri=/my_auth_callback&grant_type=client_credentials
The redirect URI needs to be an absolute URL.
And btw., you don’t need to make an extra API call to get an app access token, app id and secret can be used for that directly:
app_id|app_secret
is always a valid app access token.

Unable to POST to concourse REST api

I am unable to POST to https://ci.server.com/api/v1/teams/main/pipelines/test/jobs/hello-world/builds despite using the Auth bearer token as a header.
There is no issue with GET commands, using POSTMAN to test - is there some other auth required for POST?

calling rest api from meteor app

How can I call a rest api with authentication from meteor, appreciate if you can guide to an example, I have added the http package to the meteor project. Using advanced rest client chrome app, I am able to get the data by passing the following URL and 2 headers. This app is using the already logged in browser session.
URL: https://xxxxx:9443/ccm/oslc/contexts/_ZoC0QNS3EeGPlow7Bl9IAw/workitems
headers: Accept", "application/json"
OSLC-Core-Version", "2.0"
How can I pass the headers and user name password of the rest api service.