Creating Custom GPTs: OAuth Authentication For Custom Actions | Complete Guide β
Other Videosπ
2023-11-18
Transcript β
[00:00] welcome back y'all we're going to be looking up setting up gbts with o off authentication this is a really powerful video as you're going to be able to provide a lot of value to your end customer when it comes to gbts or in the context that you want to utilize this in A Private Matter so let's go ahead and actually jump into a real example here so you can see it working live and then we're going to go ahead and walk through through step by step how I did this I will say super ironic but when I was making the API tutorial comparative to this one this one was a lot easier here
[00:30] so oaf is really easy setup there's a little bit of errors here and there that I'm going to go ahead and clarify we're also going to be using our gbt creator to create this I'm going to walk you through step by step this isn't going to be I just hand you the code and say have fun I'm going to show you air troubleshooting I'm going to show you everything you need to know about o off and then going give you a actual perspective from a engineer here as we're building out a platform using glogle Cloud functions ourself and everything you should kind of know about that so let's go ahead and just see if this even works so the very simple tutorial we're going to do today is we're going to go go ahead and just hook
[01:01] up Google API here for the context of calendar just so you can understand the Nuance behind all of what ooth is for you to understand what ooth is just as a base level ooth gives us the ability to access data from consumers what this means is that if a consumer has a Gmail account and they go through a process like this we're going to be able to access the data found in their Gmail account such as maybe sending an email for them or receiving an email so in this context we are accessing the underlying data associated with the users calendar so I'm going to hit allow
[01:32] here and this actually shouldn't work because I actually removed authentication or which you'll learn a little bit later um see this shouldn't work so I'm going to go ahead and re uh re access or reestablish connection with this provider so to do this I'm going to go ahead and just try okay can we go ahead and authenticate again with this API because I tried this earlier just to test before this video to make sure works so I've kind of already removed it in my security measure this will all make more
[02:03] sense as we get into this video but we should be able to get a link here okay so I got it working basically I just learned something new here I got to basically train the gbt in order to request authentication again when a user doesn't have it so I'm going to go and list this again because I basically authenticated before then I removed it manually and then obviously to Showcase this working I went ahead and you know provided this little setup here this will all make more sense as we jump in more here but basically what we're going to do from here is we're going to sign in with our Google account I'm not going to show my email but I'll show you the Scopes being requested just because I
[02:34] have other emails that are personal so I'm going to click this though all right so as you see here once you get to the O off screen we're going to have our application name which going to be test calendar API we're going to learn how to set that up together here and then it's going to be the Scopes Scopes if I can speak requested here in this context we are just doing the Scopes of just seeing and downloading an individual's calendar I'm going to dive into basically everything you need to know about Scopes when it comes to Google the cloud and all of its API this can apply to other types of backend begin as well but for now I'm just going to hit allow and then let's go ahead and see it in action here once we come back you're going to see
[03:05] that green little notification here telling us we have successfully authorized oo here and we can go and proceed here so what you'll notice here is that there seems to be a glitch with open Ai and Oaths right now where it's asking me to do it again but you don't need to do it again I believe they'll probably fix this uh let me know in the comments if you found a solution to kind of troubleshoot that but for now though it still works we're going to go ahead and just say can come down here to our chat boot can you list our calendars question mark and then I hit the you know send message here and as you see here it'll be able to access your API
[03:35] and list it out I believe it's going to ask me to allow it to do this function first but this is very powerful in the context gbts this is going to show you a lot of value if you really want to make a gbt that a lot of people are going to use as now we're going to be able to access softwares outside of uh the context of the openai ecosystem and start leveraging the data there go ahead and hit allow here it's going to talk to the API here it's going to talk to specifically our data here and you're about to see the calendar that that we have here at web Cafe AI as we see this output perfect it works we're going to
[04:05] be good to go here it's going to give the relevant information the context of this API was purely to be a readon API so therefore we're not going to do any actions but you can obviously do actions with whatever API you plan on doing but as you see here it works and it's good to go once I know if this seemed a little jumpy it's because I jumped back into this recording a couple hours later as I got kicked out of gbt again because of over usage so if you want to be you know on the get-go of what I'm doing here on this channel you can go and follow me on Twitter let's go and jump back over to building out this together we're going to learn everything we need
[04:36] to know for OA you know you're going to learn you know everything that's encompassed with building out a gbt that's integrated with API so we have our fresh gbt here we are going to proceed so we're going to come over to configure and we're going to start off by going to create new action and this is where we're going to begin with the open AI specifically for the ooth to do that though we're going to come over to our gbt creator here if you want to watch a full in-depth video where we created this together you can check it out up there this is going to allow us to help create it and make this process a lot easier so you don't have to code
[05:06] anything and really make it as simple as possible but you're going to walk through this with me as if we run into errors which we will uh you can see how you can troubleshoot it and we can see how we can proceed from there so to start off here we're going to Simply outline what we plan on doing in today's context so today's example we're going to be using Google Calendars API here and we're going to be asking for the schema this has already been proctored the gbt's been proctored to help you a schema and we're going to go ahead and reference a specific form when it comes to Google o off so this is a new little trick I can show you all basically if you keep running into errors and it you
[05:36] know you get a little bit frustrated a way we can really make sure we narrow down errors is utilizing open ai's coding forms so if I grab that link right there and I go to these form real quick what you'll notice is that this entire form is dedicated towards the idea of you know OA and issues you run into oo but as you'll see if you keep scrolling down here we get possible solutions to help so what I like to do in the context you know if if you're doing something complex is get data like this and load it into the uh gbt so it can reference it and it doesn't make the same problems that maybe other people
[06:07] are facing so I'm going to hit enter here and let's go and begin here so we're going to walk through this together you're going to learn everything you need to know here and we should be getting a schema meant for the Google Calendar we go we're going need the relevant Json for this specific function we're doing with this ooth if you get anything that references comments like these slash slashes make sure to delete them as it is not permitted in schema as you'll see this is going to result in an air when we paste it over but for now we're going to go ahead and start off with this so I'm going to walk through step by step so we can just do the air troubleshooting together so I'm going to go ahead and
[06:37] come back over here I'm going to goad and paste in here and as you see we'll get an error here so it says could not parse valid open AI spec that has to do with the associated slashes here so I'm going to delete this I'm going to delete this and these slashes are just giving you reference of what's incurring in the code here I'm going delete this and as you see we have another eror here it says in component section schemas uh subsection is not an object I'm going to copy the air then I'm going to come back over here I'm going to say okay great please add the relevant
[07:10] information to solve this error you cicle in here I'm going to paste in the error here and then it should provide the relevant request that we need to do for the schema to operate in this context so as it generates here I'm actually going to pause it real quick because I want to do a specific event so in today's video we're going to do a readon scope scope in this context is BAS the permissions we have when we have access to the users app so for me I'm going to do the scope of just listing calendars we're going to say list calendars is the action we want to do this will make more sense you're going
[07:40] to be able to find out more about API documentation when you go over to Google Cloud also you can even Proctor gbt to ask what is all possible with calendar API YouTube API Gmail API or whatever API you plan on integrating in this software you could do Spotify whatever it may be perfect so now that we have this and we specifi the specific event here I'm going to come back over to gbt here I'm going to paste it in here we're going to go ahead and make sure we remove these slashes again you can also tell J gbt to stop giving you slashes but this should be sufficient for what
[08:10] we're trying to do here and as you see here so far so good we have the event above me and let me go ahead and move myself over here real quick so we have the event above me and we can go and proceed with The Oaf part okay so as you see here the oo is going to require a lot of information from us so to start off here we're going to Simply go to Google Cloud Google cloud is what's going to allow us to get access to this I'm going to explain a lot of the intricacies here but simply go to go to console or sign up and as you see here you get access to $300 of free credit but on top of that when you're doing this in a developer context it typically
[08:42] costs like no money because you're going to see there's developer quotas and I'll explain more of that when we jump into here but start off by creating a Google Cloud account so once you have created your Google Cloud account I'm going to go ahead and make sure I delete this project so basically the you know client ID and the client secrets you see here aren't going to be usable from here we're just going to go to name our project so this is going to be how you see it on your back end I'm going to say gbt for calendar and then you would during setup have set it up your organization and location and from here I'm just going to
[09:13] hit create once you have created your project here as you see you'll be able to select it right up here we're going to go ahead and activate our calendar API so I'm going to go to API and services once in API and services this is the entire Suite of Google cloud or just Google and all the different apis we have access to as you'll see there is a ton of different stuff you can do when leveraging Google's entire software infrastructure but for now our personal tutorial here and you can also search up here is going to be for Google calendar so I believe I just saw it right here so I'm going to go ahead and click Google
[09:43] Calendar API here then we hit enable this is going to allow us to get a secret key a client key everything associated with the infrastructure from Google cloud and we're going to go ahead enable here once we have enabled it we're going to have to set up some stuff here so we're going to come up here and we're say create credentials and when we hit create credentials we're going to fail to load so let me go ahead and try this again okay perfect so I just had to back out come back in all right so here's a couple things we need to understand here so for the API we're going to do the Google Calendar API here for what data we'll be accessing so
[10:14] we're going to be accessing the user data right so we're going to get the consent form all that information whatever the user uh gives the yay okay that's the calendar we're accessing here from here we're going to hit next now we're going to go ahead and name the app so this is how the app was in the front facing as you saw in the beginning of this tutorial we'll call it we call it test calendar API I believe for this one we'll call it uh GPT uh calendar and then we're going to choose our user support email so this is going to be whatever email associated with your account so here is going to be our corporate account here you can add a logo if you choose to do so for now just go ahead and add your uh email again
[10:46] here the same one you can uh for the support you can add here perfect I'm going to go ahead and save continue here so then the next question here is scope so Scopes in this context is what kind of data are we getting access to here is some important information you need to understand first thing you understand understand is that there is different severities when it comes to Scopes Scopes are are you going to be able to create an event in the so I'm going to speak in the context of calendar API are you going to be able to create an event in calendar that's going to be a higher threshold when it comes to the amount of data you access are you only going to be able to read the events in calendar
[11:16] that's going to be a lower threshold so typically actions that require or typically actions that give you the ability to delete post and and kind of more manipulate the data are going to be higher severity when it comes to threshold for security reasons um actions that are more readon and getting information are less severity so when I use the term severity in this context I'm referring to that in production you you're going to have to go through an authentication uh authentication process where Google is going to look at your app confirm that it's a okay and then
[11:46] give you the green light to use their API at scale that sounds like a lot but the process is pretty clear you can use chat GV to help you for today's video though we'll continue with just the Scopes and the scope we're going to deal with today is going to be simply a scope that allows us to read the individual's calendar as you see here we have a ton of different scopes with the uh you know front- facing description us we're just going to do the readon as you see here read only I'm going to click this and see and download any calendar you access using your Google calendar I'm going to hit click here I'm going to update and there we go so we have our scope as you
[12:18] see here there is different types of Scopes right so you have your non-sensitive Scopes your sensitive Scopes and your restricted Scopes all have their different levels of security and stuff associated with it when it comes to doing it at scale from here though we're going to go ahead and choose our application type since we're going to be using chat gbt and it's backend we're going to use web application here and the name of the application is going to be in the back end here so we're going to go ahead and just call it uh gbt uh find my event all right so from here we are going to have to add some authorized JavaScript
[12:48] Origins and authorized redirect URLs so just in the beginning implementation process here we're going to add just the the master domain found from chat gbt here so I'm going to go and copy it real quick all right here we go so I'm going to go do add it here and have it here so here is more okay let's get rid of this slashes real quick so you might be asking yourself what are these first off the authorized redirect URL is going to be the you know is it okay to come from this URL to get consent to get the data for the Scopes this will make more sense
[13:19] we're going to get an air there I'm going to teach you how to fix that in actual uh when we actually do it the authorized JavaScript Origins is how we handle requests when it comes to passing data this all you to limit and make sure that your oaf and your keys aren't getting abused as we kind of made it very clear that hey maybe we only accept requests within the chat DBT ecosystem knowing that we're going to go ahead and hit create here once we hit create we're going to go ahead and get our client ID copy that download that save it somewhere perfect so we have set up our oof to be clear here this oaf is in a
[13:51] development development phase context and what I mean by that it's not like I just created the oo I can just have a thousand people join this uh whole process we're still in the development phase here so so once we've created our app here we can go ahead and jump over to credentials and we're going to be able to see it right here as you see we named it gbt find my event and this is where we're going to see our secret don't share your secret I'm sharing my secret but I'm going to delete this project so go ahead if you want to take the time and copy that go ahead and try don't share your secret this allows so people can't abuse the underlying key and everything associated with that so
[14:22] go ahead and copy that as well okay so once we have the client ID the secret we are good to go so this is most of everything that you should have to set up for the development phase but let me go ahead and just walk you through some stuff so you can even understand this whole interface and what's even incurring here so the first thing you need to understand is that right now this o off screen is for Eternal use if you want to go ahead and have it for production or for external use we have different developers with different emails this is how you would go into testing here so I would hit confirm and
[14:52] this would prompt me to have test users test users is where you would put the emails of people that you want to test to use your app so so it's it's still internal and it's not at production level now if you want to go to production level that's going to require an entire review process that is very lengthy 46 weeks long or it could be done it could be done shorter it could be done longer whatever it may be it is more lengthy that's just uh Google's way of confirming that okay are you a legit operator here are you going to abuse your systems and stuff of this nature the next thing you should understand here is that in your enabled API
[15:23] services this is where we're going to be able to see how much usage is going towards that API so if I come over to Google calendar API here you will see that we have no usage here because we haven't called it yet but you'll see what it looks like when we do call it on top of that what you'll notice here is a thing called quotas quotas is how they limit your ability to call upon this API EG their way of ensuring that you don't abuse your systems and you have a thousand people jump on this internal app and you know just send a bunch of requests so we are limited at 10,000 which is enough for a developer to deal
[15:54] with so now that we have everything set up here let's go ahead and jump back over to CH gbt and set up our ooth which is right above me and I will move over here okay here we go so let's paste in our client ID that we got earlier boom let's paste in our secret boom and let's get some relevant information for the authorization URL token URL and scope so your scope is going to be what you enabled in the app creation process that you saw on Google Cloud that's going to be not that let me going to copy it over here that's going
[16:25] to be the exact URL that we have and if it's going to let me cop copy it that was the readon scope here if not you're going to want to add additional Scopes if you're doing more than one scope here but here is our scope so we got a read only scope here for the authorization and token Ur that's going to be dependent on your API and whatever API back end you're using as Chad gbt it should be able to help you plus you can just search it on Google so for Google the way they do o off is structured in this kind of URL here as I said before ask shbt to help you out in this context it'll be able to give you directly the type of URL you're looking for or you
[16:55] can just search it online so this is our standardized authorization URL here and our token URL and we're going to do the final uh token exchange method of basic authorization header I'm going to hit save okay so we should be good to go here but we got to go ahead and Proctor our chat gbt a little so I'm going to go and copy this I'm going to jump back over here in the middle and we're going to go ahead and proceed with creating a specific use case for gbt so we're going to say your use case is to find the users calendar using and then you're
[17:26] going to put the actions name the operation ID that we did in the configuration here and then on top of that we're going to have to actually proor it to do one other thing here before we test it in the front end it's going to have an air in the front end I left it there on purpose so that when you're dealing with documentation you know how to troubleshoot it all right so we're going to go ahead and say yes to calendars uh yes good name and give me a funny profile image let's leave it at that let's go that generate okay so that looks really crazy but we'll let it slide um as you see here we have everything fleshed out to where we want
[17:56] it didn't say the name here so I'm just going to put gbt find my calendar perfect so from here we're going to go ahead everything else can be fine as you see here you're going to really get a nice call back you're all here and I'm going to go ahead and hit save here I'm going to do it for only myself if you wanted to do it publicly you would have to provide a privacy URL we're jumped over here this isn't going to work I know it's not going to work but let's go ahead and just see you know how we troubleshoot that so I'm going to go ahead and say can you list my calendar and I'm just going to be
[18:27] right in the way so let me go move myself over here can you list my calendar and then we should get prompted here to authenticate our API all right so we're going to go ahead and hit sign in with Google API here and as you see here we're going to get this air so it's going to be access blocked this app request is invalidated so that was the URI that we set up in the original setup here but to find out what your URI is you're going to hit air details here we're going to Simply copy the URL that it says to copy so we're going to go and copy this right here command C this this
[18:58] I'm going to jump back over to Google Cloud not that one this one I'm going to go to my credentials here I'm going to go to gbt find my event this is your app here this going to add it to URI here command V and I'm going to go ahead and hit save so this is going to allow us to do authent authentication request from gbt's frontend and therefore allow our app to work in this context one thing I want to note though is do take into count that it is it does take a little bit of a couple minutes for it to activate so if you do this right away and then try to you know test it and it
[19:29] doesn't work give it a couple minutes it sometimes takes a little time for it to realize that this is a valid redirect your all all right so I waited like two minutes let's go and check it out here we're going to say can you give oh one other thing I got to show you which is really really important um not that that's still important jump back over to the editor real quick all right so what's really important in the context of ooth is sometimes individuals could revoke authentication therefore it could run into issues if they want to reauthenticate in the future so we're going to make sure and say this if a
[20:00] user is not authenticated make sure to present them with the O off consent screen so let me go and move myself over here so you can see what I'm doing here uh so what this does though is kind of the issue I ran with a ran into in the beginning of the video where I didn't actually add this prompt here but this is actually pretty important because this makes sure that if a user uses this gbt and they run it to like
[20:31] hey you're not authenticated it doesn't keep telling it like you know don't use me now it knows to provide the URL again to give the user another chance to authenticate themselves so for knowing this I'm going to go ahead and confirm this again jump back over here we're going to go ahead and hit view we're going to hit can you list my calendar perfect it's prompting us again to provide authentication when you click this you're going to find your emails I have some private emails there so I'm going to go ahead and just click it and then show you the uh off screen we got our app name gbt calendar the specific
[21:01] Scopes we requested here which was just reading for the calendar here I'm going to hit allow and then this is going to give access to our specific calendars as you may already know this is going to be able to be used at scale so 100 people could in theory use this app of course it would have to be you know approved but as you see we have signed in and for some reason right now there's just a little glitch where you it prompts you to do it again but you don't need to do it anymore so we can go ahead and say can you list my calendar and this will access the API here and we're going to be able to see on the quota end and then I'm going to give you perspective as an engineer make sure you say allow of
[21:32] stuff to understand when it comes to production stuff to understand when it comes to cost and you know everything of this nature but as you see here we have our calendar it's light blue I'm the owner and default reminders 10 minutes before events pop up so we got everything we care about we've successfully uh connected oo make sure to use our gbd gbt customizer if you're having issues with this as we've really structured this to really help people to do more custom action and now let's go and jump into everything we need to understand about Google Cloud which can be applied to AWS
[22:04] or whatever backend you plan on using or whatever API structure using typically a lot of these have similar structuring when it comes to pricing and quota usage we have a little bit of usage right there our first customer no I'm joking but as you come over here we have a quot it doesn't show it's so small it doesn't even go up to a percent but keep in mind the way this works is that once you reach your quota in the day you can't access the API anymore therefore you will run into errors if this basically says 100% % another thing to keep in mind is that cloud usage and stuff of this nature when it comes to API is very
[22:34] cost effective you can do a lot of operations for pennies on the dollar um on top of that if you are familiar with backends that use that we usually typically host these kind of functions on past gbt would be like Firebase and Firebase FL uh Firebase Cloud functions this is kind of where you do it on more of a private sector and a private app that you developed on your back end but in the context of Chad gbt you don't necessarily have to worry about this as much because we were just using it to Leverage The API access that is given in this context knowing that though as I described before once you're prepare to
[23:06] go into production if we come over to our ooth consent screen you're going to need to go to production and understand two major things first thing you need to understand is that the uh process to make an app uh production level is going to require a review process by Google oaf which takes between 4 to 6 weeks this could be done earlier this could be done later big indicator on whether or how fast this whole process is expediated is dependent on what kind of Scopes you request EG if you if you start requesting a lot of restrictive Scopes that can manipulate the end user data at a high level you're going to
[23:37] deal with a longer process comparative to a uh comparative to requesting very low low sensitive or not really high um High restrictive Scopes right like if I'm just going to get access and read your calendar I'm probably going to get requ or probably going to get accepted and verified pretty quick so keep that in mind when building out your application next thing to keep out keep in mind is the underlying a API you are using has its own review process what do I mean by that that means that once my oo screen has been confirmed and greenlighted and I can use it in a production when I say production by the
[24:08] way that means like everyone in the public can get access to it so it's more it's a live product basically so once you have an O off screen that gives you that you've been greenlighted for the production status there is another review process you might be asking what is the next review process the next review process is for quota usage and the way that works is you're going to be able to click this um and I believe let me see if I can find it oh yeah edit quota and you are going to go ahead and hit submit request here if you go over it though you're going to need a I stopped there a little bit because it looked a little bit different than the one I'm traditionally used to which is YouTube's API so it seems a little bit simpler in
[24:39] this context um all you would need to do in this context is simply put in your new limit and then give like a really small description knowing that though every single API has its own thresholds that is very simple for Google Calendars trust me YouTube is a very lengthy process to get higher requests on it but with that being said today we have learned how to successfully connect ooth I'm going to go ahead and expand myself here we've learned to successfully connect ooth here uh from start to finish you have an idea even to the extent of production so if you feel like you learn something today make sure to leave a like it's completely free if you
[25:11] like this kind of content you can actually see a playlist at the end here where I'm diving into gbt showing you how to make public private ones other prevalent information when it comes to apis and stuff of this nature also I'm just jumping into like cool gbts that I found and just like little tutorials of that way but without further Ado I'll see you in the next video thanks for tuning in and yes surprise I'm an AI Avatar make sure to explore more here at Corbin AI where we demystify AI for your personal and business life until next
[25:46] time