Module Make.OAuth2
OAuth 2.0 authentication.
val authorize : ?state:string -> ?force_reapprove:bool -> ?disable_signup:bool -> id:string -> [ `Token of Uri.t | `Code of Uri.t option ] -> Uri.tauthorize client_id responsestarts the OAuth 2.0 authorization flow. This isn't an API call—it's the web page that lets the user sign in to Dropbox and authorize your app. Theclient_idis the app's key, found in the App Console. After the user authorizes your app, they will be sent to your redirect URI. The type of response varies based on theresponse:`Token redirect_uri(also called "implicit grant") returns the bearer token by redirecting the user toredirect_uriafter the authorization has completed. Extract the token usingtoken_of_uri. This is useful for pure client-side apps, such as mobile apps or JavaScript-based apps.
`Code uifu = Some redirect_uri, returns a code via by redirecting the user toredirect_uri(extract the code usingcode_of_uri) or, ifu = None, presents the code to use user (on screen) who will be invited to copy it in your app. The code should then be converted into a bearer token usingOAuth2.token. This is recommended for apps that are running on a server.
Note that the URI for
`Tokenand`Codemust be registered in the App Console; even 'localhost' must be listed if it is used for testing.- parameter state
Up to 200 bytes of arbitrary data that will be passed back to your redirect URI. This parameter should be used to protect against cross-site request forgery (CSRF). See Sections 4.4.1.8 and 4.4.2.5 of the OAuth 2.0 threat model spec.
- parameter force_reapprove
Whether or not to force the user to approve the app again if they've already done so. If
false(default), a user who has already approved the application may be automatically redirected to the URI specified byredirect_uri. Iftrue, the user will not be automatically redirected and will have to approve the app again.
- parameter disable_signup
When
true(default isfalse) users will not be able to sign up for a Dropbox account via the authorization page. Instead, the authorization page will show a link to the Dropbox iOS app in the App Store. This is only intended for use when necessary for compliance with App Store policies.
type code= stringThe authorization code, which can be used to attain a bearer token by calling
token.
val code_of_uri : Uri.t -> (code * string) optioncode_of_uri ureturn the code and state from the redirect URIuafter a`Codeauthorization.
val token_of_uri : Uri.t -> (token * string) optiontoken_of_uri uparse the URI coming from a`Tokenflow and extract the token and state.
val token : ?redirect_uri:Uri.t -> code -> id:string -> secret:string -> token Lwt.ttoken code id secretacquire a token once the user has authorized the app. Only applies to apps using the authorization`Codeflow.codeis the code acquired by directing users toOAuth2.authorize ~response_type:`Code.idthis should be the app's key (found in the App Console).secretthis parameter should be present and should be the app's secret.- parameter redirect_uri
Only used to validate that it matches the original
authorize, not used to redirect again.