Error 403, Metadata scope doesn't allow format FULL . Web application Gmail API get message through postman - gmail-api

I'm getting forbidden 403 error when hitting Gmail API get message through postman please help me how to solve this. error
https://www.googleapis.com/gmail/v1/users/userId/messages
this url for getting message list
https://www.googleapis.com/gmail/v1/users/userId/messages/id
this is for getting message for particular id
I can able to hit the get message list API but get Message API not working for me
I'M doing all these stuff through postman
error message :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Metadata scope doesn't allow format FULL"
}
],
"code": 403,
"message": "Metadata scope doesn't allow format FULL"
}
}

This is another disappointing design in the Gmail API. I resolved this issue with the following steps:
Remove GmailScopes.GMAIL_METADATA from scopes setup.
Remove the credential file from your local FileSystem. This file is generated by Google's Authorization Flow which store your credential locally.
Re authorize your app by signing in again https://accounts.google.com/o/oauth2/auth?access_type=offline....
Hope this helps you guys out.

Related

How can i use Gmail API to send an email as per the

I need help on to Read Unreaden emails count / send an email to specific or group of people and search with senders id or date to find a specific email using API Only, no programming I did the action like this https://www.googleapis.com/gmail/v1/users/gmailid#gmail/profile on the browser and i got the output like below
{
"error": {
"errors": [{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}],
"code": 401,
"message": "Login Required"
}
}
I know, i have to pass oAuth token or client id and client secreat to the url, but i dont know how can i pass that info through URL.
Also i tried in Post-Man and i could not able tocreate the oAuth token, it is asking call back and redirect url that i dno know.
Can some body give me the idea pleaseI need only API Solution, because i need to work on API stuff, i can successfully implemented the same using java. But i could not able to do this using API ( Am not using any programming to handle the API, only Browser calls and most likely Post-Man only)
You only need the access token to do the HTTP request. In this case, the syntax to get the Gmail profile would be this:
https://www.googleapis.com/gmail/v1/users/USERID/profile?access_token=ACCES_TOKEN
You can easily request the tokens (and do HTTP requests) in the OAuth 2.0 Playground. You can also read more about the getProfile request of the Gmail API here.
EDIT:
To get the number of unread messages, you have to use the q parameter, and change your request to messages:
https://www.googleapis.com/gmail/v1/users/me/messages?q=is:unread&access_token=ACCESS_TOKEN

Google Drive upload file rest api returns 401 error

I want to store my json object to google drive.
And google authentication is working fine.
But when I am calling google drive api, it returns 401 error.
I set authentication, content-type, and content-length to api headers.
Not sure why this happen.
401: Invalid Credentials
Invalid authorization header. The access token you're using is either expired or invalid.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization",
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
Suggested action: Refresh the access token using the long-lived refresh token. If this fails, direct the user through the OAuth flow, as described in Authorizing Your App with Google Drive.

App Engine Admin API Error - The "appengine.applications.create" permission is required

We would like to automatically create a project ID and install our ULAPPH Cloud Desktop application using the App Engine Admin API (REST) and Golang.
https://cloud.google.com/appengine/docs/admin-api/?hl=en_US&_ga=1.265860687.1935695756.1490699302
https://ulapph-public-1.appspot.com/articles?TYPE=ARTICLE&DOC_ID=3&SID=TDSARTL-3
We were able to get a token but when we tried to create a project ID, we get the error below.
[Response OK] Successful connection to Appengine Admin API.
[Token] { "access_token" : "TOKEN_HERE", "expires_in" : 3599, "token_type" : "Bearer" }
[Response Code] 403
[Response Body] { "error": { "code": 403, "message": "Operation not allowed", "status": "PERMISSION_DENIED", "details": [ { "#type": "type.googleapis.com/google.rpc.ResourceInfo", "resourceType": "gae.api", "description": "The \"appengine.applications.create\" permission is required." } ] } }
We are just using the REST API calls. Request for token was successful as you can see above and the scope is ok as well. Now, when we posted the request to create application, we are having the error that says "appengine.application.create" permission required.
How do we specify the permission?
What are the possible reasons why we are getting that error? Do we missed to send a field in JSON or in query?
As per below link, we just need to pass the json containing the id and location. We also just need to pass the token in the Authorization header. The same logic I have used successfully in accessing Youtube, Drive APIs etc so not sure what needs to be done since I have followed the docs available.
I have also posted the same issue in Google Groups and now waiting for their reply.
It seems you've given no details about how you set up the account you're using to authorize the request. You'll need to make sure the appengine.applications.create permission is given to the account you're using, as mentioned in the error text. You can use the Google Identity and Access Management (IAM) API for this.
(by the way, I'd given this answer in the original thread, although you didn't reply or seem to take action on it. check it out! this is likely the solution you need!)

How to detect if Google account hasn't Gmail

How can I recognize Google accounts without Gmail?
I use OAuth2 for authorization and then download user messages.
But if Google account hasn't Gmail, then I receive the error while getting data from api:
{
"errors": [
{
"domain": "global",
"reason": "failedPrecondition",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
What is the best way to detect accounts without Gmail?
Now I just send test GET request to gmail-api and check that it returns OK.
But I'm looking for best solution.

GAE Endpoint Security testing with local dev envrionment

I am trying to secure my GAE service endpoints. So I added the following annotations to my service class and deploy this service to GAE:
#Api(name="mytestapi",version="v2", description="An API for testing" ,
scopes = {Constants.EMAIL_SCOPE},
clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, Constants.API_EXPLORER_CLIENT_ID},
audiences = {Constants.ANDROID_AUDIENCE})
When I try to access my service with the API explorer at the Google Development Server everything works fine. I receive the answer that the User is authorized but when I try to access this service from my local machine I just receive the message that the user is not authorized
GET http://localhost:8888/_ah/api/mytestapi/v2/ .....
Authorization: Bearer ya29.1.AADtN_X_Uku4qj0ehwOwRqLLmKvbIOOYOCC2KXOnVskUXT7Yy19bNsiIGepXTzI
X-JavaScript-User-Agent: Google APIs Explorer
401 Unauthorized
- Show headers -
{
"error": {
"message": "User is Not Valid",
"code": 401,
"errors": [
{
"domain": "global",
"reason": "required",
"message": "User is Not Valid"
}
]
}
}
Any Idea what I have missed to configure or what I am doing wrong?
Regards
Michael
In the credentials of your application, on the console Google, you have to add the localhost origin in the Javascript Origins, section Client ID for web application.

Resources