Google API "Daily Limit for Unauthenticated use Limit" 403 Error ... iOS

I am getting started with both iOS developer and Google API. I am learning both of them at the same time, so apologies if this is a newbie question.

The Parsing Error has been canceled and replaced with a new API error below

I am trying to write an application that will tell me that at the time of an API request whether the calendar is in the middle of an event or not.

I tried using this answer posted for a similar question.

My code looks like this: (LOOK AT THE UPDATE NUMBER)

let json = "{ \"timeMin\": \(currentDate), \"timeMax\": \(currentDate)}"
urlString = "https://www.googleapis.com/calendar/v3/freeBusy"


let url = URL(string: urlString)!
let jsonData = json.data(using: .utf8, allowLossyConversion: false)!

var request = URLRequest(url: url)
request.httpMethod = HTTPMethod.post.rawValue
request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")
request.httpBody = jsonData

Alamofire.request(request).responseJSON {
    (response) in
    print (response)
    }

      

And I get the following output: (Note: this is fixed by specifying in the json parameter from which the calendar is pulling information)

SUCCESS: {
    error =     {
        code = 400;
        errors =         (
                        {
                domain = global;
                message = "Parse Error";
                reason = parseError;
            }
        );
        message = "Parse Error";
    };
}

      

I'm not sure how to proceed from this, also makes a free POST request even the best way to solve my problem?


UPDATE:

So, I found out that in my body parameter I did not specify which calendar to request information: I made the following settings:

    var body : Parameters  = [
    "timeMin": dateString,
    "timeMax": dateString,
    "items": [
        [
            "id": CALENDAR_ID
        ]]
    ]

    Alamofire.request(url, method: HTTPMethod.post, parameters: body, encoding: JSONEncoding.default).responseJSON {
            (response) in
                print(response)
    }
}

      

However, I am now getting the following error:

SUCCESS: {
    error =     {
        code = 403;
        errors =         (
                        {
                domain = usageLimits;
                extendedHelp = "https://code.google.com/apis/console";
                message = "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.";
                reason = dailyLimitExceededUnreg;
            }
        );
        message = "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.";
    };
}

      

+3


source to share


1 answer


So I figured out both problems:

FIRST-PARSE ERROR

This error in the freebusy context came from my POST parameter without specifying which calendars to fetch information from

SOLUTION: (important part in bold)

var body : Parameters  = [
    "timeMin": dateString,
    "timeMax": dateString,
    "items": [                //make sure you have this (plus next 4 lines)
        [
           "id": CALENDAR_ID
        ]
    ]
]

      

SECURE SECURITY USE ERROR



I solved it with this question .

In short, all discovery-based APIs require your calls to be identified. The error you are getting is what I usually see when the Google API is unable to detect your application. You can usually make several Unidentified calls, but you will almost certainly run into a significantly lower "unidentified" quota pretty quickly. You can also authenticate with OAuth (which identifies your app), or you can provide an API key (which identifies your app), or you can do both.

Decision

I solved it by adding the API key to my url like this (don't click):

https://www.googleapis.com/calendar/v3/freeBusy ? keys = PASTEKEYHERE

+2


source







All Articles