Authentication and Authorization

Version 1.1 - Updated on 9/23/2016

Contents

getAuthorizeUrl

Returns an authorization URL that a user can redirect to in order to start the Oauth 2.0 process.

  • Returns: — authorization url

init(initObject)

Initialization method used to setup the SDK. Must be the first API called.

  • Parameters:
    • initObject — Lifecycle callbacks and parameters
    • initObject.clientKey — Key for your application
    • initObject.clientSecret — Secret for your application
    • initObject.callbackUrl — Callback URL for your application
    • initObject.htmlEscape — HTML escapes all responses when set. Defaults to true.
    • InitObject.authToken — Access token that may optionally be passed to bypass authentication. The SDK will run the postAuthenticated callback and be in a logged in state if this parameter is set.
    • initObject.refreshToken — Refresh token that may optionally be passed with an access token. The SDK will automatically try to refresh if a token expires and a refresh token is present.
    • initObject.postInitializepostInitialize is called when the api is initialized and ready to be used. The callback contains a boolean value to let a client know if the API has been initialized successfully.
    • initObject.postAuthenticatedpostAuthenticated is called after the SDK has attempted to authenticate a user, either by exchanging an access token or receiving it in the init method. The callback has two arguments, a boolean flag which is set when authentication was successful, and an error code which is set only when the SDK could not authenticate.
    • initObject.onAuthInvalidated — Method called after the SDK has received a 401.
  • Returns: None. This method is asynchronous. Clients should use callback methods.

isAuthenticated()

Helper method that a client can use to check if the SDK has authenticated a user by completing the OAuth 2.0 process

  • Returns: boolean value that is set if the SDK has successfully completed the OAuth 2.0 process.

isInitted()

Helper method that you can use to check if the SDK has been successfully initialized.

  • Returns: boolean value that is set if the SDK has been successfully initialized.

ready(callback)

JQuery-like ready handler that can be used to execute code after init completes.

  • Parameters: callback — Function that you can run when the SDK is ready for use. This function does not take any argument.
  • Returns: None. This method is asynchronous. Clients should use callback methods.

token(requestObject)

Final part of the oauth 2.0 process. Exchanges an authorization code for access tokens. This API can only be called after thingspace.cloud.init() has been called. This function is called automatically by the SDK when an authorization code is present in the URL. After success or failure, postAuthenticated lifecycle method is called.

  • Parameters:
    • requestObject — Callbacks and parameters
    • requestObject.success — Success callback function. Returns the response in the first argument.
    • requestObject.failure — Failure callback function. Returns the response in the first argument.
  • Returns: None. This method is asynchronous. Clients should use callback methods.

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.