• jhenny
  • NEWBIE
  • 80 Points
  • Member since 2008

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 30
    Replies
How to authenticate google service account for google adword api. By using this document. 
https://developers.google.com/accounts/docs/OAuth2ServiceAccount
My code Is as following :
public class GoogleAdWordApi{
     public Static String getAccessToken(){
        String accesstoken = '';
        
        String headerStr64 = EncodingUtil.base64Encode(Blob.valueOf('{"alg":"RS256","typ":"JWT"}'));
        headerStr64 = headerStr64.split('=')[0];

        String str = '{"iss":"965360208690-a6qbrksf61b5dl7punv126ntb5aspu93@developer.gserviceaccount.com",';
        str += '"scope":"' + 'https://www.googleapis.com/auth/prediction' + '",';
        str += '"aud":"' + 'https://accounts.google.com/o/oauth2/token' + '",';
        str += '"exp":' + system.now().addminutes(30).gettime()/1000 + ',';
        str += '"iat":'+system.now().gettime()/1000;
        str += '}';
        
        System.debug('@@@ str==>'+str);
        
        String claim_set64 = EncodingUtil.base64Encode(Blob.valueOf(str));
        claim_set64 = claim_set64.split('=')[0];
        System.debug('@@ claim_set64==>'+claim_set64);
        
        //make signature
        String sigInputstr =   headerStr64 + '.' + claim_set64 ;
        Blob signInputByteData = Blob.valueOf(sigInputstr);
        Blob signByteData = System.Crypto.signWithCertificate('RSA-SHA256',signInputByteData,'privatekey');
        String sigStr64 = EncodingUtil.base64Encode(signByteData);
        System.debug('@@@ sigStr64==>'+sigStr64);
        sigStr64 = sigStr64.split('=')[0];
        System.debug('@@@ sigStr64==>'+sigStr64);
        
        String jwtStr = headerStr64 + '.' + claim_set64 + '.' + sigStr64;
        
        System.debug('@@@ jwtStr==>'+jwtStr);
        
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://accounts.google.com/o/oauth2/token');
        req.setMethod('POST');
        req.setHeader('Host','accounts.google.com');
        req.setHeader('Content-Type','application/x-www-form-urlencoded');
        String body = 'grant_type='+ EncodingUtil.urlEncode('urn:ietf:params:oauth:grant-type:jwt-bearer','UTF-8');
        body += '&assertion=' + jwtStr;
        req.setBody(body);
        System.debug('@@ body==>'+body);
        Http http = new Http();
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());    
        
        return accesstoken;
    }
}
--------------------------
Please tell me what is going worng with it.
The case feed dev guide specifies a method to interact with the social publisher,
i.e.: SocialPostAPIName.SocialPost

Found here:
https://developer.salesforce.com/docs/atlas.en-us.case_feed_dev.meta/case_feed_dev/case_feed_dev_guide_component_interactions.htm

What are the values that can be specified for "SocialPostAPIName"

I have tried "Twitter" unsuccessfully
  • November 23, 2015
  • Like
  • 0

Is there any information about SAML & the new communities product,

specifically for a portal user scenario?

 

SAML seems to fail in an SP intiated flow where the user is a portal user.

 

Is there an event listener for when a PIN unlocks the app?

 

 

I.e.  document.addEventListener("pinUnlockSuccess", onPinUnlockFunction, false);

 

The log seems to write the following, but I don't know how to subscribe to it in the container:

SFSecurityLockout|Sending passcode flow completed notification with validation success = 1

 

I need to register some soups when the application loads,

but this needs to happen after PIN unclock or it will error.

Is it possible to change how SFDC asserts the NameIDFormat when SFDC is IdP?

 

SP metadata specifies to send it like this:

 

        <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:transient</NameIDFormat>

        <NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>

 

But SFDC sends this:

 

      <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">jhenson@cleartask.com</saml:NameID>

 

Thanks

  • January 11, 2013
  • Like
  • 0

Any way configure a Salesforce Authentication Provider in a salesforce production org that allows the users logging in to provide credentials from a Sandbox org or a Production org?

 

(the documentation says it will not work with the testing URL, but can it be done with the actual URL)

  • October 18, 2012
  • Like
  • 0

Seems like the new setMock test methods don't like when you have DML that creates your test data prior to doing your mock callouts. I.e.:

 

 

    @isTest static void TestCallout() {              
   
    //  Test data   
        Account a = new Account(Name = 'test', BillingStreet='test', BillingCountry='United States',BillingCity='test',BillingState='California');
        insert a; 
   		
        // This causes a fake response to be generated     
        Test.setMock(WebServiceMock.class, new MyCalloutClass());
        
        // Call the method that invokes a callout 
    	MyCalloutClass p = new MyCalloutClass();
        String output = p.DoCallout();
        
        // Verify that a fake result is returned     
        System.assertEquals('Mock response', output); 
    }

 

I get the error "You have uncommitted work pending. Please commit or rollback before calling out"

 

I guess the workaround is maybe to use loadData, but seems strange that this error would appear in a test method

  • October 04, 2012
  • Like
  • 0

Currently getting a standard sfdc "unauthorized..." message using a sfdc portal user to access the SP from a SFDC portal that is the IdP. The profile access was granted in the SP settings. 

 

Basically I just log in as the portal user and hit the IdP initated URL & the message is displayed.

 

Is there a known issue around this?

 

Thanks

  • September 26, 2012
  • Like
  • 0

With SFDC as an IdP, is it possible to map SFDC Federated ID to a Username in the SP?  

The SP system does not support a Federated ID field. 

 

I tried to set this up with 2 salesforce instances (hub & spoke) but it did not work. IdP instance was setup to send the SFDC username of the user in the SP instance in the Federated ID field.

  • August 23, 2012
  • Like
  • 0
When we install our package in a Summer '17 sandbox org we get an error stating our main component is not found:

org.auraframework.throwable.quickfix.DefinitionNotFoundException: No COMPONENT named markup://ascendix_search:Search found

Is this a known issue with Summer '17 or has there been a change in how components should be defined?
The case feed dev guide specifies a method to interact with the social publisher,
i.e.: SocialPostAPIName.SocialPost

Found here:
https://developer.salesforce.com/docs/atlas.en-us.case_feed_dev.meta/case_feed_dev/case_feed_dev_guide_component_interactions.htm

What are the values that can be specified for "SocialPostAPIName"

I have tried "Twitter" unsuccessfully
  • November 23, 2015
  • Like
  • 0
I have a custom Knowledge Bar console component that publishes event named "publisher.customActionMessage". And then I've two custom publisher actions for Case Feed that subscribe to this event. Following is the code:
 
// code in KnowledgeSidebar.page
Sfdc.canvas.publisher.publish({ name:"publisher.customActionMessage", payload: { actionName: "CaseSMSPublisher", message: "Hello world" } });

// code in CaseSMSPublisher.page
Sfdc.canvas.publisher.subscribe([{
        name: "publisher.customActionMessage",
        onData: function(e) {
          alert(e.message);
        }
      }]);
I've enabled logging and it shows that the event is being fired when clicking on a button in the sidebar, but the custom publisher action neither show any alert message nor prints in the console. It would be great if someone could help out.
 
How to authenticate google service account for google adword api. By using this document. 
https://developers.google.com/accounts/docs/OAuth2ServiceAccount
My code Is as following :
public class GoogleAdWordApi{
     public Static String getAccessToken(){
        String accesstoken = '';
        
        String headerStr64 = EncodingUtil.base64Encode(Blob.valueOf('{"alg":"RS256","typ":"JWT"}'));
        headerStr64 = headerStr64.split('=')[0];

        String str = '{"iss":"965360208690-a6qbrksf61b5dl7punv126ntb5aspu93@developer.gserviceaccount.com",';
        str += '"scope":"' + 'https://www.googleapis.com/auth/prediction' + '",';
        str += '"aud":"' + 'https://accounts.google.com/o/oauth2/token' + '",';
        str += '"exp":' + system.now().addminutes(30).gettime()/1000 + ',';
        str += '"iat":'+system.now().gettime()/1000;
        str += '}';
        
        System.debug('@@@ str==>'+str);
        
        String claim_set64 = EncodingUtil.base64Encode(Blob.valueOf(str));
        claim_set64 = claim_set64.split('=')[0];
        System.debug('@@ claim_set64==>'+claim_set64);
        
        //make signature
        String sigInputstr =   headerStr64 + '.' + claim_set64 ;
        Blob signInputByteData = Blob.valueOf(sigInputstr);
        Blob signByteData = System.Crypto.signWithCertificate('RSA-SHA256',signInputByteData,'privatekey');
        String sigStr64 = EncodingUtil.base64Encode(signByteData);
        System.debug('@@@ sigStr64==>'+sigStr64);
        sigStr64 = sigStr64.split('=')[0];
        System.debug('@@@ sigStr64==>'+sigStr64);
        
        String jwtStr = headerStr64 + '.' + claim_set64 + '.' + sigStr64;
        
        System.debug('@@@ jwtStr==>'+jwtStr);
        
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://accounts.google.com/o/oauth2/token');
        req.setMethod('POST');
        req.setHeader('Host','accounts.google.com');
        req.setHeader('Content-Type','application/x-www-form-urlencoded');
        String body = 'grant_type='+ EncodingUtil.urlEncode('urn:ietf:params:oauth:grant-type:jwt-bearer','UTF-8');
        body += '&assertion=' + jwtStr;
        req.setBody(body);
        System.debug('@@ body==>'+body);
        Http http = new Http();
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());    
        
        return accesstoken;
    }
}
--------------------------
Please tell me what is going worng with it.

Is there any information about SAML & the new communities product,

specifically for a portal user scenario?

 

SAML seems to fail in an SP intiated flow where the user is a portal user.

 

Is there an event listener for when a PIN unlocks the app?

 

 

I.e.  document.addEventListener("pinUnlockSuccess", onPinUnlockFunction, false);

 

The log seems to write the following, but I don't know how to subscribe to it in the container:

SFSecurityLockout|Sending passcode flow completed notification with validation success = 1

 

I need to register some soups when the application loads,

but this needs to happen after PIN unclock or it will error.

I'm creating a small barcode scanner app using the latest mobile sdk (based on cordova 2.3.0).  Once I've dropped the .mm, .cpp and .h files into the Plugins directory, the build fails on the following line of the scanner code:

 

#import <Cordova/CDVPlugin.h>

 

saying that CDVPlugin can't be found.  The only way that I've been able to get the Xcode compiler to be able to see this file is to copy it from the SalesforceHybridSDK.framework/Headers folder and drop it into the Plugins folder.  The knock-on effects of this are that I have to copy most of the other header files across as well.

 

This works, but it feels wrong - I'm sure there's something obvious that I've missed.

 

Currently getting a standard sfdc "unauthorized..." message using a sfdc portal user to access the SP from a SFDC portal that is the IdP. The profile access was granted in the SP settings. 

 

Basically I just log in as the portal user and hit the IdP initated URL & the message is displayed.

 

Is there a known issue around this?

 

Thanks

  • September 26, 2012
  • Like
  • 0

Hello,


I am creating a multiple file upload, one of the thing that is failing for me is "Calling controller method from javascript, Golbal Remote call for is not working"

So I created a simple example to test and that not working either, Here is my Controller class and page, Its not showing me a alert on page load.  What am I doing wront here ?

Class
===========

global with sharing class myControllerTest {
    
    @RemoteAction
    global static String getID(String parentId){
        return parentId;
    }
}




Page
============

<apex:page >
<head>
   <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
   <script type="text/javascript">
     j$=jQuery.noConflict();
     
     myControllerTest.getID('Hello Salesforce', function(result,event){
        if(event.status == true){
            alert(result);
        }else{
            alert(event.message);
        }
    }, {escape: false});
   </script>
</head>   
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

With SFDC as an IdP, is it possible to map SFDC Federated ID to a Username in the SP?  

The SP system does not support a Federated ID field. 

 

I tried to set this up with 2 salesforce instances (hub & spoke) but it did not work. IdP instance was setup to send the SFDC username of the user in the SP instance in the Federated ID field.

  • August 23, 2012
  • Like
  • 0

When a Visualforce Page1 calls Visualforce Page2 and Visualforce Page2 has a extension to an Apex class with a constructor that contains the following line of code

 

"ApexPages.currentPage().getHeaders().get('Referer')"

 

How can the class be tested when being called by a Apex test class instead of a Visualforce page?

 

The result of "ApexPages.currentPage().getHeaders().get('Referer')" is setting a class property that is being used by other methods of the class.

 

//*****************************************************

public class Payment_Extension
{
    private Payment__c payment;
    private ApexPages.StandardSetController myController;
    private Payment currentPayment;
    private boolean isReceivable;    
    
    //********************************************************************************
    public Payment_Extension(ApexPages.StandardSetController stdController)
    {
        system.debug('PaymentReceivable_Extension');
        payment = (Payment__c)stdController.getRecord();
        myController = stdController;
        isReceivable = ApexPages.currentPage().getHeaders().get('Referer').contains('tabspayreceivable');     
    }
    
    //********************************************************************************
    public List<selectOption> getReceivableTypes()
    {
        if(isReceivable)
        {
            return currentPayment.ReceivableTypes();
        }
        else
        {
            return currentPayment.PayableTypes();
        }
    }
}

//*****************************************************

Hi,

which are the modifications to do on SFHbridApp.js, bootconfig.js and bootstrap.html of the app sample VFConnector, to not have initial authentication?

Thanks in advance.

  • June 20, 2012
  • Like
  • 0

HI All,

 

We are using Salesforce as IdP and we enabled also the Single Sign-on settings in Salesforce. Now we want to use Heroku and Play! to access Salesforce and the Play! application is the service provider.

 

This all works fine when using an internal salesforce user, but we want to use this functionality with a customer portal user but how can we manage that.

 

I found a doc where it states that we need to add the portal_id and the organization_id to the saml assertion but we only have a saml request and the saml assertion comes from the identity provider i think.

 

Help would be appreciated.

 

thx Sven

  • March 08, 2012
  • Like
  • 0

I receieved a question via email which I'll repost here, and answer:

 

Hi Greg,

I'm trying to interpret the Force.com Streaming API limits noted in the documentation. These are my questions:

1. "Maximum Number of Topics: 20" - is that referring to the total number of PushTopic records? Is that limit per user or per org?

2. "Maximum number of clients (subscribers) per topic: 10" - does that mean if I build a VF page that allows users to select streams to "follow" and deploy that into an org with 100 users, only 10 of them can subscribe to the same topic? Is that limit of 10 at any given moment, or is there a duration for which a subscription lives and "blocks" other subscribers?

  • February 27, 2012
  • Like
  • 0