Google Endpoints iOS error

186 views
Skip to first unread message

Matt

unread,
Jun 27, 2017, 8:17:24 PM6/27/17
to Google Cloud Endpoints

I am trying to use GTLRservice and the associated queries generated by Service Generator in my iOS application.

I have generated an API key for IOS, and set it to the service objects "service.APIkey" field. I have set my bundle identifier for the key (in Google Cloud Console) to the same one I am using in my XCode project.

I have also created a client ID and set the bundle identifier in cloud console.

When trying to access cloud endpoints from my iOS app, i get this error: 403 Requests from this ios client application are blocked.

It seems that GTLRservice doesn't have access to my bundle identifier for some reason? Also, do I need to set the Client ID inside of my xcode project?

I have used endpoints in the past (before endpoints 2.0 frameworks), and there was no need to go through oauth2 authentication or provide an API key.

I can access my api in .../_ah/api/explorer, so I know it's working partially at least. How do I get it to work in iOS correctly?

Below is example code.

To reiterate, I have created on Google Cloud Console: API key for iOS using my bundle identifier Client ID for iOS using my bundle identifier

GTLRApiService *service = [[GTLRApiService alloc] init];
service.APIKey = @"...";
service.retryEnabled = YES;

GTLRApi_Request *object = [[GTLRApi_Request alloc] init];
object.String = @"Test"

GTLRApiQuery_Go *query = [GTLRApiQuery_Go queryWithObject:object];
[service executeQuery:query completionHandler:^(GTLRServiceTicket *ticket, GTLRApi_Response *response, NSError *error){
    NSLog(@"%@",response.Value);
    NSLog(@"%@",error.description);
    NSLog(@"%@",[[NSBundle mainBundle] bundleIdentifier]);
}];

The error it gives me is:

Error Domain=com.google.HTTPStatus Code=403 "403 Requests from this ios client application <empty> are blocked." UserInfo={NSLocalizedDescription=403 Requests from this ios client application <empty> are blocked.}

Here is from my endpoints api on python app engine:

@endpoints.api(name='api', version='v1', description="API", hostname="my-app.appspot.com", allowed_client_ids=['<MY_CLIENT_ID>.apps.googleusercontent.com'], auth_level=endpoints.AUTH_LEVEL.REQUIRED)
class API(remote.Service):

Thanks, please let me know what I am missing. This is not well documented.

Am I required to log in with Oauth2 in my app? Is there a way to log in with the service account behind the scenes so I don't have to prompt the user to log in with Oauth2?

Dan Ciruli

unread,
Jun 27, 2017, 9:21:44 PM6/27/17
to Google Cloud Endpoints, mattpem...@gmail.com

Right now, you're setting the auth level asĀ auth_level=endpoints.AUTH_LEVEL.REQUIRED

That's why it is requiring OAuth. Try setting that to endpoints.AUTH_LEVEL.NONE instead.
Reply all
Reply to author
Forward
0 new messages