I'am working on a project which has an API built with symfony2 as backend. After logging in and getting token when I try to sent get request with generated token this issue happend
-->"code": 401,
"message": "Invalid credentials"
attached my config.yml and security.yml setting
security.yml file
requet get to backend api
It seem that your postman request is malformated
The correct format for the Authorization bearer header is:
Authorization: Bearer yourToken
Tell me if the error message change !
I hope this will solve your issue
Related
I'm trying to get info from google analitics from api but always get this error:
I've made OAuth2 and got token, but I don't know where to put it.
Can someone explain what have I done wrong?
The issue you are having is that the call has not bee authorized. To access private user data you need permission which means you need to send a properly authorized access token along with your request
This is sent as an Authorization header, something like this.
curl -X POST -H "Authorization: bearer xxxxxxxxxxxxxx" "https://analyticsreporting.googleapis.com/v4/reports:batchGet"
I am trying to send fcm message to specific topic by using cURL command but it says error like
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
I used server key from firebase console
I followed this FCM Documentation
How to resolve this 401 error.
Actually I think why, this is because you need a Service account that will handle it for you.
So follow the steps here and this will make you generate a new key pair. With this key, you can get the access token from a code (see in python below but the documentation has support for NodeJS / Java) :
def _get_access_token():
"""Retrieve a valid access token that can be used to authorize requests.
:return: Access token.
"""
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'service-account.json', SCOPES)
access_token_info = credentials.get_access_token()
return access_token_info.access_tokenmessaging.py
And you just have to print this value, copy-paste it and use it as the Bearer OAuth 2 access token.
I have successfully created a Bearer Token and I would like to request data from the Tour Planning/VRP API. However, I always get the following response:
{
"error": "Forbidden",
"error_description": "These credentials do not authorize access"
}
If I try to make the request with the APIKey instead of the Bearer Token, I don't get authentification.
Could you please tell me how a can make a request using my Token?
I am currently trying to do the request with Postman.
Thanks
Manuel
Not able to establish watch channel. getting unauthorized push notification error 401. Done all required settings for web_hook to work.added domain in domain verification tab. Stuck here for weeks. plz help me out. thanks.
first of all you should have a ssl certificate as push notification only work on https:// you can read all about the requirement here https://developers.google.com/google-apps/calendar/v3/push
but the thing missing in the above link is you shoul have the authentication token set on the callback url ( similar to that when you set before calling a google API.. ) and dont forget to take access token from database (assuming that you had it stored at the time of authentication) as system will not read it from session on callback url.
You need to add this value to the headers of your request:
"Authorization: Bearer user_token"
You can get user token with a GET Google_Http_Request to https://www.googleapis.com/oauth2/v3/token
PHP example to get Google token:
Use Google APIs PHP Client library.
$TokenRequest = new Google_Http_Request(
"https://www.googleapis.com/oauth2/v3/token",
"GET"
);
$Token = $Client->getAuth()->authenticatedRequest($TokenRequest);
I am currently trying to use the Google Identity Toolkit Token Service REST API (https://developers.google.com/identity/toolkit/reference/securetoken/rest/v1/token) to generate an access token which I can use in my backend server.
When I specifying "authorization_code" as "grant_type" and the gtoken cookie value after authentication as "code" in the POST request to https://securetoken.googleapis.com/v1/token, I get a 403 response with the following error message:
{
"error": {
"code": 403,
"message": "The request cannot be identified with a client project. Please pass a valid API key with the request.",
"status": "PERMISSION_DENIED"
}
}
I inspected the gtoken value via a JWT decoder and it looks to be correct in format. In particular I can see that aud is set to my application/client ID. The documentation doesn't say anything about specifying API key - usually I would expect that to be specified in the Authorization header. So I am not sure what I am missing here.
Any pointer to this matter would be appreciated.
An API key in the URL is required when calling Google Identity Toolkit APIs (including the Token Service API). However, I would suggest you take a look at the new version of the service - Firebase Authentication. The Firebase Auth SDK has build-in support of the Token Service API.