Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
669 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

enter image description here

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

enter image description here

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...