Authentication And Authorization

Authentication and Authorization

Contents

iOS SDK invokes Verizon Personal Cloud Storage APIs to begin the authentication and authorization flow. When you start integrating iOS SDK with your app, you will need to provide the Key and Secret generated for your app by Key Management, as well as the Callback URL that you entered when you have registered your app.

Refer to API Developer Guide for detailed information on the API authentication and authorization process.

NOTE: The Callback URL is case sensitive.

Authentication and Authorization API Calls

The gateway to access Personal Cloud Storage APIs is the PCAPISDK class. This class includes all fo the authentication and authorization api calls listed below.

  • authenticateClient - this API is used to present OAuth 2.0 login screen. Based on the response from OAuth 2.0 login, the completion handler returns either the authorization code or an error message. You can exchange the authorization code for an access token and a refresh token. The access token will remain in the keychain until it expires or the user logs out.
  • fetchAccessToken - retrieves access token.
  • isUserLoggedIn - returns YES if the user has an access token
  • logout - logs the user out from the current session. Removes the access token that is stored in keychain. Returns YES if the token is successfully removed.
  • refreshSession - refreshes current session. Once the session has been refreshed, the authentication credentials are returned with the completion block.

Authenticating Your App

The following code snippet allows you to begin the authorization.

  1. Include VerizonCloudAPI.framework header file in you class:

    Code Sample

    #import <VerizonCloudAPI/VerizonCloudAPI.h>
    
  2. Create a PCClientCredentials object using client_id, client_secret and redirect_url:

    Code Sample

    PCClientCredentials *clientCredentials = [[PCClientCredentials alloc] initWithClientID:@"Client_ID"
            
    clientSecret:@"Client_Secret"
            
    redirectURL:@"Redirect_URL"
            
    keychainID:@"Keychain_ID"];                                                                                                                                                                  
    
  3. Call authenticate:fromViewController:withCompletionHandler: method :

    Code Sample

    [[PCAPISDK sharedInstance] authenticateClient:clientCredentials fromViewController:self.navigationController withCompletionHandler:^(PCAuthenticationResponse  *authenticationCredentials, PCOAuthLoginPageResponse *OAuthLoginPageResponse, PCAPIQueryResponse *response) {
                
            if ([authenticationCredentials isAuthenticated]) {
                  
                NSLog(@"User authenticated");
            } else {
                
                NSLog(@"User not authenticated");
            }
        }]; 
                
    

Authentication Response

  • PCAuthenticationResponse stores access token, refresh token and expiry time received as a part of OAuth 2.0 authentication process.
  • PCOAuthLoginPageResponse stores either auth_code or access_denied response received on OAuth 2.0 login web page.
  • PCAPIQueryResponse stores http response, http error and json response, received as a part of login web service call.

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