What are APP_CLIENT_ID and SERVER_CLIENT_ID and where do I find them?

烈酒焚心 提交于 2020-01-24 06:15:25

问题


I'm trying to implement server-side API access for my iOS app. The Google docs (here) mention APP_CLIENT_ID and SERVER_CLIENT_ID in their code sample in step 2.

Here's their code:

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [GIDSignIn sharedInstance].clientID = @"APP_CLIENT_ID";
  [GIDSignIn sharedInstance].serverClientID = @"SERVER_CLIENT_ID";

  // Additional scopes, if any
  // [GIDSignIn sharedInstance].scopes = @[ @"other_scope" ];

  return YES;
}

What are APP_CLIENT_ID and SERVER_CLIENT_ID and where do I find them? Are they both in the Google Developers Console?


回答1:


Replace the APP_CLIENT_ID string with an installed application OAuth 2.0 Client ID for the iOS app, configured by adding credentials with the following radio selected:

The SERVER_CLIENT_ID string stores a Web server OAuth 2.0 Client ID and is configured from the console as:

The server client ID, listed under "Client ID for web application" in the console, is only used if you retrieve an authorization code to authorize your server in hybrid authorization scenarios and is optional. When specifying a SERVER_CLIENT_ID, you retrieve an authorization code and can exchange the code for a refresh token on your backend services when you authorize the user from the iOS app.

The client IDs traditionally have been configured via the Google Developer Console as described here. However, using the latest libraries, you can generate a configuration and load it as explained in the iOS developer guide for Google Sign-In.



来源:https://stackoverflow.com/questions/30879990/what-are-app-client-id-and-server-client-id-and-where-do-i-find-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!