Learn how to configure a Google application as your identity provider.
- [Narrator] Got a relying party application started in visual studio. Now I want to go into the Google developer dashboard and set up Google as my identity provider. So I've gone to console.developers.google.com, logged in with my Google ID, I'm going to click on the menu up here and create a new project. I'm going to go ahead and call that my auth demo and hit create. You can see it takes me into the dashboard and I'm going to go down to the credentials tab because I want to get this set up to allow me to log in with O auth.
I'm going to go ahead and leave the name as it is. For the bundle idea I need to go back to my visual studio and go to my info p list for my iOS project, then I can get my bundle identifier from the bundle identifier field here. Just copy that. I'll come paste it in there, and I'm going to go ahead and create, I'm going to leave out the store ID and the team ID. You can see I got a client ID, so copy that and it's going to show up down here under my O auth client ID's.
If we go back into visual studio, we'll expand that, I'm going to come into the shared project. We've got this my class here that's empty. I'm going to rename the file, I think we want to call that something else. We'll just call that constants, and we'll do the same for the class. We don't really need a constructor here. We're going to use this for is to store some of these key bits of information about the service so I'm going to create a read only string, client ID and we'll paste in that value we just got.
You can see it's a nice long string that ends with this apps.googleuserconsent.com. I'm going to copy that and we'll paste because we're going to use these for a couple other values. So in addition to that client ID, I'm going to need a redirect URL. This is where, when we go to Google, in the mobile app and we hit Google and we log in it's where it's going to redirect back to.
And so here, we've got this backwards, so we'll do com.googleuserconsent.apps and then the value, so now I can come to the end here and clip that off. And we also want to provide more than that, that's just the base, so we want to come in and do something like this, Oauthresponse. So you can see it looks like a URI, that's our custom scheme at the beginning there, and then we have the Oauthresponse at the end.
And now we're going to need some other URL's here. So I'm going to copy that again, public static readonly, but this time instead of the redirect URL I need to know the authorized URL. So where are we going to start to authorize this request? What's the base? And that's going to be https://accounts.google.com/o/oauth2/v2/auth.
So that's where we're going to start the authentication process and we have the redirect URL but we also need a little bit more information because in addition to authorizing we're also going to get some tokens. So I'm going to put a token URL, so after we've authorized we might want to go get the token for the user. So again we'll do www and that's googleapis.com/oauth2/v4/token. And now we've got our token URL, our authorized URL, and our redirect URL, we've got our client ID, the last thing we need it's what called a scope.
So I'm going to add one more and that's a read only string, call it scope, I'm just going to put profile, cause at some point when we go out and we ask for that consent, the scope is what defines what we're asking for, what set of data are we requesting permissions to. So we've set up our identity provider, we've taken that information that we got out there in terms of those keys and we've put that into these static fields that we can now leverage inside our application.
- Authenticating users of mobile apps
- Working with the Xamarin.Auth library
- Making authenticated web calls
- Storing and retrieving credentials
- Using an identity management service
- Configuring and extracting claims
- Using claims